React version: current main (b685b40; experimental Fragment refs)
Steps To Reproduce
- Render a Fragment ref whose first focusable element is nested inside a host child.
- Call focus() on the Fragment ref.
- Call blur() on the same Fragment ref.
Link to code example:
const fragmentRef = React.createRef();
<Fragment ref={fragmentRef}>
<div>
<input id="nested-input" />
</div>
</Fragment>;
fragmentRef.current.focus();
fragmentRef.current.blur();
The existing Fragment refs fixture contains this shape: its first focusable child is a button nested inside a div.
The current behavior
focus() finds and focuses the nested input, but blur() leaves it focused. blur() only compares the active element with the Fragment direct host children, so it sees the containing div rather than the focused descendant.
The expected behavior
blur() should remove focus when the active element is anywhere within a Fragment host child, matching the deep traversal behavior of focus().
React version: current main (b685b40; experimental Fragment refs)
Steps To Reproduce
Link to code example:
The existing Fragment refs fixture contains this shape: its first focusable child is a button nested inside a div.
The current behavior
focus() finds and focuses the nested input, but blur() leaves it focused. blur() only compares the active element with the Fragment direct host children, so it sees the containing div rather than the focused descendant.
The expected behavior
blur() should remove focus when the active element is anywhere within a Fragment host child, matching the deep traversal behavior of focus().