-
Notifications
You must be signed in to change notification settings - Fork 49k
Bugfix: Infinite loop in beforeblur event #19053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If the focused node is hidden by a Suspense boundary, we fire the beforeblur event. Our check for whether a tree is being hidden isn't specific enough. It should only fire when the tree is initially hidden, but it's being fired for updates, too.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ec032c8:
|
Details of bundled changes.Comparing: 1d85bb3...ec032c8 react-dom
react-reconciler
Size changes (stable) |
Details of bundled changes.Comparing: 1d85bb3...ec032c8 react-dom
react-reconciler
ReactDOM: size: 0.0%, gzip: 0.0% Size changes (experimental) |
Should only beforeblur fire if the node was previously visible. Not during updates to an already hidden tree. To optimize this, we should use a dedicated effect tag and mark it in the render phase. I've left this for a follow-up, though. Maybe can revisit after the planned refactor of the commit phase.
@@ -333,13 +333,21 @@ export function findCurrentHostFiberWithNoPortals(parent: Fiber): Fiber | null { | |||
return null; | |||
} | |||
|
|||
// This function detects when a Suspense boundary goes from visible to hidden. | |||
// It returns false if the boundary is already hidden. | |||
// TODO: Use an effect tag. And move this to ReactFiberCommitWork. | |||
export function isFiberSuspenseAndTimedOut(fiber: Fiber): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is also used by Scopes for traversal, will this change affect that too? See:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, didn't search for other uses.
I moved the logic into the commit phase.
isFiberSuspenseAndTimedOut is used elsewhere, so I inlined the commit logic into the commit phase itself.
954048d
to
1f52fe2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these changes! Makes sense to me :)
1f52fe2
to
ec032c8
Compare
Thanks for the quick review! |
If the focused node is hidden by a Suspense boundary, we fire the beforeblur event. Our check for whether a tree is being hidden isn't specific enough. It should only fire when the tree is initially hidden, but it's being fired for updates, too.
To optimize this, we should use a dedicated effect tag and mark it in the render phase. I've left this for a follow-up, though. Maybe can revisit after the planned refactor of the commit phase.