-
Notifications
You must be signed in to change notification settings - Fork 48.4k
Allow fragment refs to attempt focus/focusLast on nested host children #33058
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
fe51ced
to
4958839
Compare
Comparing: e5a8de8...0daf77b Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
4958839
to
bc5f128
Compare
bc5f128
to
0daf77b
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.
@jackpope and I discussed the tradeoff of looking through top-level host elements to expose focus
and decided that the feature is more useful if we expose this capability.
That would mean that this is a semantically meaningful change:
const ref = useRef(null);
return (
<div ref={ref}>
<a />
</div>
);
// --> calling .focus will now focus the anchor element
const ref = useRef(null);
return (
<React.Fragment ref={ref}>
<div>
<a />
</div>
<React.Fragment/>
);
#33058) This enables `focus` and `focusLast` methods on FragmentInstances to search nested host components, depth first. Attempts focus on each child and bails if one is successful. Previously, only the first level of host children would attempt focus. Now if we have an example like ``` component MenuItem() { return (<div><a>{...}</a></div>) } component Menu() { return <Fragment>{items.map(i => <MenuItem i={i} />)}</Fragment> } ``` We can target focus on the first or last a tag, rather than checking each wrapping div and then noop. DiffTrain build for [4206fe4](4206fe4)
#33058) This enables `focus` and `focusLast` methods on FragmentInstances to search nested host components, depth first. Attempts focus on each child and bails if one is successful. Previously, only the first level of host children would attempt focus. Now if we have an example like ``` component MenuItem() { return (<div><a>{...}</a></div>) } component Menu() { return <Fragment>{items.map(i => <MenuItem i={i} />)}</Fragment> } ``` We can target focus on the first or last a tag, rather than checking each wrapping div and then noop. DiffTrain build for [4206fe4](4206fe4)
This enables
focus
andfocusLast
methods on FragmentInstances to search nested host components, depth first. Attempts focus on each child and bails if one is successful. Previously, only the first level of host children would attempt focus.Now if we have an example like
We can target focus on the first or last a tag, rather than checking each wrapping div and then noop.