[DOM] Blur focused descendants in Fragment refs - #37125
Merged
Merged
Conversation
|
Comparing: b685b40...408004c Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
daltino
approved these changes
Jul 26, 2026
daltino
left a comment
There was a problem hiding this comment.
The PR patches blurActiveElementWithinFragment to ensure it properly handles active elements nested within fragment refs by switching from instance.blur() to activeElement.blur(). It also introduces a test to validate that focus is removed correctly in this scenario. The changes are concise, align with the contribution guidelines, and add essential test coverage.
jackpope
approved these changes
Jul 29, 2026
jackpope
left a comment
Collaborator
There was a problem hiding this comment.
I agree this makes sense here and is now more consistent with focus. Thanks for contributing!
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 29, 2026
## Summary `FragmentInstance.blur()` only matched the active element against the first level of host children. If the focused element was nested inside one of those children, `focus()` could reach it but `blur()` would leave it focused. This treats an active element contained by a Fragment host child as part of the Fragment and blurs the active element itself. It also adds regression coverage for a nested input. Fixes #37124. ## How did you test this change? - `yarn test ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn test --prod ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn prettier` - `yarn linc` - `yarn flow dom-node` DiffTrain build for [1724e9c](1724e9c)
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 29, 2026
## Summary `FragmentInstance.blur()` only matched the active element against the first level of host children. If the focused element was nested inside one of those children, `focus()` could reach it but `blur()` would leave it focused. This treats an active element contained by a Fragment host child as part of the Fragment and blurs the active element itself. It also adds regression coverage for a nested input. Fixes #37124. ## How did you test this change? - `yarn test ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn test --prod ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn prettier` - `yarn linc` - `yarn flow dom-node` DiffTrain build for [1724e9c](1724e9c)
github-actions Bot
pushed a commit
to code/lib-react
that referenced
this pull request
Jul 30, 2026
## Summary `FragmentInstance.blur()` only matched the active element against the first level of host children. If the focused element was nested inside one of those children, `focus()` could reach it but `blur()` would leave it focused. This treats an active element contained by a Fragment host child as part of the Fragment and blurs the active element itself. It also adds regression coverage for a nested input. Fixes react#37124. ## How did you test this change? - `yarn test ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn test --prod ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn prettier` - `yarn linc` - `yarn flow dom-node` DiffTrain build for [1724e9c](react@1724e9c)
github-actions Bot
pushed a commit
to code/lib-react
that referenced
this pull request
Jul 30, 2026
## Summary `FragmentInstance.blur()` only matched the active element against the first level of host children. If the focused element was nested inside one of those children, `focus()` could reach it but `blur()` would leave it focused. This treats an active element contained by a Fragment host child as part of the Fragment and blurs the active element itself. It also adds regression coverage for a nested input. Fixes react#37124. ## How did you test this change? - `yarn test ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn test --prod ReactDOMFragmentRefs-test --runInBand` (65 tests passed) - `yarn prettier` - `yarn linc` - `yarn flow dom-node` DiffTrain build for [1724e9c](react@1724e9c)
jackpope
added a commit
that referenced
this pull request
Aug 12, 2026
focus() passes through portals as it attempts focus down the fiber tree. blur() exited early based on a containment check, causing it to stop at portals. The result could be a focused element that cannot be blurred. Follow up to #37125, which made blur() apply recursively to be consistent with focus().
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 12, 2026
focus() passes through portals as it attempts focus down the fiber tree. blur() exited early based on a containment check, causing it to stop at portals. The result could be a focused element that cannot be blurred. Follow up to #37125, which made blur() apply recursively to be consistent with focus(). DiffTrain build for [278d318](278d318)
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 12, 2026
focus() passes through portals as it attempts focus down the fiber tree. blur() exited early based on a containment check, causing it to stop at portals. The result could be a focused element that cannot be blurred. Follow up to #37125, which made blur() apply recursively to be consistent with focus(). DiffTrain build for [278d318](278d318)
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.
Summary
FragmentInstance.blur()only matched the active element against the first level of host children. If the focused element was nested inside one of those children,focus()could reach it butblur()would leave it focused.This treats an active element contained by a Fragment host child as part of the Fragment and blurs the active element itself. It also adds regression coverage for a nested input.
Fixes #37124.
How did you test this change?
yarn test ReactDOMFragmentRefs-test --runInBand(65 tests passed)yarn test --prod ReactDOMFragmentRefs-test --runInBand(65 tests passed)yarn prettieryarn lincyarn flow dom-node