Skip to content

Conversation

@tconkling
Copy link
Contributor

@tconkling tconkling commented Mar 24, 2021

If a ComponentInstance is reordered in the DOM - which can happen as the result of a script re-run - its iframe will be re-mounted, and get a new contentWindow. A Component sends messages to Streamlit via its contentWindow -- and since we currently don't detect a change to contentWindow, a remounted Component iframe will send messages that just get dropped on the floor by ComponentRegistry.

This PR detects contentWindow changes during component update and re-registers the component's message listener.

(Most of the hard work of discovery, making a repro-able test case, and finding the solution is thanks to @erumoico: https://github.com/erumoico/streamlit-issue_2720)

Fixes #2720

Copy link
Collaborator

@kmcgrady kmcgrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fantastic. Thanks for helping this out!

@tconkling tconkling merged commit f0b94c4 into streamlit:develop Mar 29, 2021
@tconkling tconkling deleted the tim/ComponentReorderingBug branch March 29, 2021 17:47
tconkling added a commit that referenced this pull request Mar 30, 2021
* develop:
  Set baseUrl to .
  Speed up CircleCI more (#3025)
  Add events to keep track of theme changes and other theme stats (#3012)
  Have MetricsManager enqueue events when disconnected (#3011)
  Fix for query param issue with base url (#2894)
  Add fuzzy search to selectbox (#2933)
  Informative repr methods for our python classes (#3027)
  ComponentInstance: handle iframe changes (#3015)
tconkling added a commit to tconkling/streamlit that referenced this pull request Mar 30, 2021
* st_form:
  Set baseUrl to .
  Speed up CircleCI more (streamlit#3025)
  Add events to keep track of theme changes and other theme stats (streamlit#3012)
  Have MetricsManager enqueue events when disconnected (streamlit#3011)
  Fix for query param issue with base url (streamlit#2894)
  Add fuzzy search to selectbox (streamlit#2933)
  Informative repr methods for our python classes (streamlit#3027)
  ComponentInstance: handle iframe changes (streamlit#3015)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some instances of my component are load as empty when I change their order

2 participants