fix(flow-react): render React adapter once when moved while connecting#24661
Open
totally-not-ai[bot] wants to merge 3 commits into
Open
fix(flow-react): render React adapter once when moved while connecting#24661totally-not-ai[bot] wants to merge 3 commits into
totally-not-ai[bot] wants to merge 3 commits into
Conversation
A ReactAdapterElement placed inside a dialog was rendered twice. When a dialog opens it attaches the adapter element and then immediately moves it in the DOM (disconnect + reconnect) within the same task. Each connect dispatches a 'flow-portal-add' event, and Flow schedules a React portal for it. The matching 'flow-portal-remove' listener was attached from an effect inside FlowPortal, which only runs after React commits the portal. Because the element was moved before that commit, the 'flow-portal-remove' event dispatched on disconnect was lost, the first portal was never removed, and the reconnect added a second portal targeting the same element. Register the removal listener synchronously while handling the 'flow-portal-add' event so the removal is never missed, regardless of when React commits the portal. Fixes #24660
Contributor
Condense the explanatory comment for the synchronous flow-portal-remove listener to match the surrounding code style. No behavior change.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



A ReactAdapterElement placed inside a dialog was rendered twice. When a
dialog opens it attaches the adapter element and then immediately moves it
in the DOM (disconnect + reconnect) within the same task. Each connect
dispatches a 'flow-portal-add' event, and Flow schedules a React portal for
it. The matching 'flow-portal-remove' listener was attached from an effect
inside FlowPortal, which only runs after React commits the portal. Because
the element was moved before that commit, the 'flow-portal-remove' event
dispatched on disconnect was lost, the first portal was never removed, and
the reconnect added a second portal targeting the same element.
Register the removal listener synchronously while handling the
'flow-portal-add' event so the removal is never missed, regardless of when
React commits the portal.
Fixes #24660