Repository navigation
Let React commit into its containers while a plugin mount is pending - #5837
Merged
Merged
Conversation
Contributor
|
Thanks @zom-2018 for the PR. This repo approves new contributors before it reviews their PRs, so this PR now closes on its own. That is expected. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ), post a link to this PR, and explain what it changes and why. A maintainer then adds you to the allow list and can reopen the PR. |
Collaborator
|
/approve @zom-2018 |
Contributor
|
Approved @zom-2018 for PRs. The name now stays on the allow list. The author can open a PR now. |
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.
Human comments
What was wrong
runWithPluginDomIsolationAsynckeepsisolationDepth > 0until a content-scriptmountpromise settles. Keeping it acrossawaitis intended and tested, but it also covers bb's own React commits that run in that window.refusePluginReparentallows a fresh React-owned node (parentNode === null) only when the new parent has a React fiber. React's root container and portal containers have no fiber; React marks them with__reactContainer$…/_reactListening…instead. So while any plugin's async mount is pending, React's insert of bb's<div data-bb-plugin-app-overlays>into#rootis refused, and no plugin's app overlays reach the page. Repro and evidence: #5836.What changed
apps/app/src/lib/foreign-dom-mutation-guard.ts: when a fresh React-owned node is inserted, a React root or portal container now counts as a React parent, the same way a fiber-backed element already did. Moves of attached React nodes to a new parent are still refused during isolation, and isolation acrossawaitis unchanged.This deviates from the direction suggested in #5836 (drop isolation across
await), because the existing test "keeps isolation across await and event listeners" pins that behavior as intended.One trade-off: a plugin that first detaches a React-owned node and then inserts it directly into a React container (for example
document.bodyonce it hosts a portal) is no longer refused. Moving a node out of its current React parent is still refused.No wire, CLI, or plugin API changes.
How you verified
foreign-dom-mutation-guard.test.tsx: while an async isolation is pending, React commits a child into its root container and into a portal container. Without the fix it fails (expected null to be an instance of HTMLDivElement); with the fix it passes, with zero refusals and no warning.pnpm exec vitest run --config vitest.config.ts src/lib/foreign-dom-mutation-guard.test.tsx src/lib/plugin-frontend-reload.test.ts: 52 passedpnpm exec turbo run typecheck --filter=@bb/app: passesoxfmt/oxlinton the two files: cleanFixes #5836