Embedding HTML with components.html


I was trying to embed an HTML of network analysis into my streamlit app. The HTML is a dynamic HTML. and as soon as I click on a button it acts very weirdly. The whole app renders into the place of the HTML code. And within the small window, the HTML code works fine. Please refer to the screenshots below.

Screenshot1 - The HTML page being shown. At this stage, I click on the + sign next to cluster analysis.
Screenshot2 - The app opens within the app.
Screenshot3 - I navigate to the page where it should be shown.
Screenshot4 - The HTML works fine within the smaller application.

Code I used -

HtmlFile = open(“exp_and_voting.html”, ‘r’, encoding=‘utf-8’)
source_code_2 = HtmlFile.read()
components.html(source_code_2, height=700)

System Configurations -
Streamlit configuration - 0.79.0
Python - Python 3.8.5
OS - MacOS BigSur 11.2
Spyder Version - 4.1.5