Skip to content

Commit a8615f8

Browse files
committed
Allow fragment refs to attempt focus/focusLast on nested host children (#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)
1 parent 1264bca commit a8615f8

24 files changed

+207
-273
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.2.0-native-fb-4a702865-20250507
1+
19.2.0-native-fb-4206fe49-20250507

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<e3421c1b910601339cb6e1b7a4ebcbbc>>
10+
* @generated SignedSource<<024a4b5a330c173972bc1922c4d45df1>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-4a702865-20250507";
407+
exports.version = "19.2.0-native-fb-4206fe49-20250507";
408408
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<eec1e2fe40d9636c573721db2deaff83>>
10+
* @generated SignedSource<<451dbf7cdd650df9ba2d4fea55567259>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-4a702865-20250507";
206+
exports.version = "19.2.0-native-fb-4206fe49-20250507";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<eec1e2fe40d9636c573721db2deaff83>>
10+
* @generated SignedSource<<451dbf7cdd650df9ba2d4fea55567259>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-4a702865-20250507";
206+
exports.version = "19.2.0-native-fb-4206fe49-20250507";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<00e844f86af1d5010341db0b6b2e2313>>
10+
* @generated SignedSource<<f740d8242681d4e21185a7d53d3dfe94>>
1111
*/
1212

1313
/*
@@ -253,30 +253,18 @@ __DEV__ &&
253253
c
254254
) {
255255
for (; null !== child; ) {
256-
if (5 === child.tag) {
257-
if (
258-
fn(child, a, b, c) ||
259-
(searchWithinHosts &&
260-
traverseVisibleHostChildren(
261-
child.child,
262-
searchWithinHosts,
263-
fn,
264-
a,
265-
b,
266-
c
267-
))
268-
)
269-
return !0;
270-
} else if (
271-
(22 !== child.tag || null === child.memoizedState) &&
272-
traverseVisibleHostChildren(
273-
child.child,
274-
searchWithinHosts,
275-
fn,
276-
a,
277-
b,
278-
c
279-
)
256+
if (
257+
(5 === child.tag && fn(child, a, b, c)) ||
258+
((22 !== child.tag || null === child.memoizedState) &&
259+
(searchWithinHosts || 5 !== child.tag) &&
260+
traverseVisibleHostChildren(
261+
child.child,
262+
searchWithinHosts,
263+
fn,
264+
a,
265+
b,
266+
c
267+
))
280268
)
281269
return !0;
282270
child = child.sibling;
@@ -26395,7 +26383,7 @@ __DEV__ &&
2639526383
FragmentInstance.prototype.focus = function (focusOptions) {
2639626384
traverseVisibleHostChildren(
2639726385
this._fragmentFiber.child,
26398-
!1,
26386+
!0,
2639926387
setFocusOnFiberIfFocusable,
2640026388
focusOptions,
2640126389
void 0,
@@ -26406,7 +26394,7 @@ __DEV__ &&
2640626394
var children = [];
2640726395
traverseVisibleHostChildren(
2640826396
this._fragmentFiber.child,
26409-
!1,
26397+
!0,
2641026398
collectChildren,
2641126399
children,
2641226400
void 0,
@@ -26951,11 +26939,11 @@ __DEV__ &&
2695126939
};
2695226940
(function () {
2695326941
var isomorphicReactPackageVersion = React.version;
26954-
if ("19.2.0-native-fb-4a702865-20250507" !== isomorphicReactPackageVersion)
26942+
if ("19.2.0-native-fb-4206fe49-20250507" !== isomorphicReactPackageVersion)
2695526943
throw Error(
2695626944
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2695726945
(isomorphicReactPackageVersion +
26958-
"\n - react-dom: 19.2.0-native-fb-4a702865-20250507\nLearn more: https://react.dev/warnings/version-mismatch")
26946+
"\n - react-dom: 19.2.0-native-fb-4206fe49-20250507\nLearn more: https://react.dev/warnings/version-mismatch")
2695926947
);
2696026948
})();
2696126949
("function" === typeof Map &&
@@ -26992,10 +26980,10 @@ __DEV__ &&
2699226980
!(function () {
2699326981
var internals = {
2699426982
bundleType: 1,
26995-
version: "19.2.0-native-fb-4a702865-20250507",
26983+
version: "19.2.0-native-fb-4206fe49-20250507",
2699626984
rendererPackageName: "react-dom",
2699726985
currentDispatcherRef: ReactSharedInternals,
26998-
reconcilerVersion: "19.2.0-native-fb-4a702865-20250507"
26986+
reconcilerVersion: "19.2.0-native-fb-4206fe49-20250507"
2699926987
};
2700026988
internals.overrideHookState = overrideHookState;
2700126989
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -27139,5 +27127,5 @@ __DEV__ &&
2713927127
listenToAllSupportedEvents(container);
2714027128
return new ReactDOMHydrationRoot(initialChildren);
2714127129
};
27142-
exports.version = "19.2.0-native-fb-4a702865-20250507";
27130+
exports.version = "19.2.0-native-fb-4206fe49-20250507";
2714327131
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<8c07e592447741b1345a345f9bdc0ffe>>
10+
* @generated SignedSource<<950f499fb445608f3818fd73537f2e36>>
1111
*/
1212

1313
/*
@@ -166,23 +166,18 @@ function findCurrentHostFiberImpl(node) {
166166
}
167167
function traverseVisibleHostChildren(child, searchWithinHosts, fn, a, b, c) {
168168
for (; null !== child; ) {
169-
if (5 === child.tag) {
170-
if (
171-
fn(child, a, b, c) ||
172-
(searchWithinHosts &&
173-
traverseVisibleHostChildren(
174-
child.child,
175-
searchWithinHosts,
176-
fn,
177-
a,
178-
b,
179-
c
180-
))
181-
)
182-
return !0;
183-
} else if (
184-
(22 !== child.tag || null === child.memoizedState) &&
185-
traverseVisibleHostChildren(child.child, searchWithinHosts, fn, a, b, c)
169+
if (
170+
(5 === child.tag && fn(child, a, b, c)) ||
171+
((22 !== child.tag || null === child.memoizedState) &&
172+
(searchWithinHosts || 5 !== child.tag) &&
173+
traverseVisibleHostChildren(
174+
child.child,
175+
searchWithinHosts,
176+
fn,
177+
a,
178+
b,
179+
c
180+
))
186181
)
187182
return !0;
188183
child = child.sibling;
@@ -15009,7 +15004,7 @@ function removeEventListenerFromChild(
1500915004
FragmentInstance.prototype.focus = function (focusOptions) {
1501015005
traverseVisibleHostChildren(
1501115006
this._fragmentFiber.child,
15012-
!1,
15007+
!0,
1501315008
setFocusOnFiberIfFocusable,
1501415009
focusOptions,
1501515010
void 0,
@@ -15024,7 +15019,7 @@ FragmentInstance.prototype.focusLast = function (focusOptions) {
1502415019
var children = [];
1502515020
traverseVisibleHostChildren(
1502615021
this._fragmentFiber.child,
15027-
!1,
15022+
!0,
1502815023
collectChildren,
1502915024
children,
1503015025
void 0,
@@ -17040,14 +17035,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1704017035
};
1704117036
var isomorphicReactPackageVersion$jscomp$inline_2009 = React.version;
1704217037
if (
17043-
"19.2.0-native-fb-4a702865-20250507" !==
17038+
"19.2.0-native-fb-4206fe49-20250507" !==
1704417039
isomorphicReactPackageVersion$jscomp$inline_2009
1704517040
)
1704617041
throw Error(
1704717042
formatProdErrorMessage(
1704817043
527,
1704917044
isomorphicReactPackageVersion$jscomp$inline_2009,
17050-
"19.2.0-native-fb-4a702865-20250507"
17045+
"19.2.0-native-fb-4206fe49-20250507"
1705117046
)
1705217047
);
1705317048
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17069,10 +17064,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1706917064
};
1707017065
var internals$jscomp$inline_2528 = {
1707117066
bundleType: 0,
17072-
version: "19.2.0-native-fb-4a702865-20250507",
17067+
version: "19.2.0-native-fb-4206fe49-20250507",
1707317068
rendererPackageName: "react-dom",
1707417069
currentDispatcherRef: ReactSharedInternals,
17075-
reconcilerVersion: "19.2.0-native-fb-4a702865-20250507"
17070+
reconcilerVersion: "19.2.0-native-fb-4206fe49-20250507"
1707617071
};
1707717072
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1707817073
var hook$jscomp$inline_2529 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17176,4 +17171,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1717617171
listenToAllSupportedEvents(container);
1717717172
return new ReactDOMHydrationRoot(initialChildren);
1717817173
};
17179-
exports.version = "19.2.0-native-fb-4a702865-20250507";
17174+
exports.version = "19.2.0-native-fb-4206fe49-20250507";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5bd38ede9798f5981361d6ce89995d36>>
10+
* @generated SignedSource<<c1dc5ee67868d8c95d8059b7651113c6>>
1111
*/
1212

1313
/*
@@ -166,23 +166,18 @@ function findCurrentHostFiberImpl(node) {
166166
}
167167
function traverseVisibleHostChildren(child, searchWithinHosts, fn, a, b, c) {
168168
for (; null !== child; ) {
169-
if (5 === child.tag) {
170-
if (
171-
fn(child, a, b, c) ||
172-
(searchWithinHosts &&
173-
traverseVisibleHostChildren(
174-
child.child,
175-
searchWithinHosts,
176-
fn,
177-
a,
178-
b,
179-
c
180-
))
181-
)
182-
return !0;
183-
} else if (
184-
(22 !== child.tag || null === child.memoizedState) &&
185-
traverseVisibleHostChildren(child.child, searchWithinHosts, fn, a, b, c)
169+
if (
170+
(5 === child.tag && fn(child, a, b, c)) ||
171+
((22 !== child.tag || null === child.memoizedState) &&
172+
(searchWithinHosts || 5 !== child.tag) &&
173+
traverseVisibleHostChildren(
174+
child.child,
175+
searchWithinHosts,
176+
fn,
177+
a,
178+
b,
179+
c
180+
))
186181
)
187182
return !0;
188183
child = child.sibling;
@@ -15711,7 +15706,7 @@ function removeEventListenerFromChild(
1571115706
FragmentInstance.prototype.focus = function (focusOptions) {
1571215707
traverseVisibleHostChildren(
1571315708
this._fragmentFiber.child,
15714-
!1,
15709+
!0,
1571515710
setFocusOnFiberIfFocusable,
1571615711
focusOptions,
1571715712
void 0,
@@ -15726,7 +15721,7 @@ FragmentInstance.prototype.focusLast = function (focusOptions) {
1572615721
var children = [];
1572715722
traverseVisibleHostChildren(
1572815723
this._fragmentFiber.child,
15729-
!1,
15724+
!0,
1573015725
collectChildren,
1573115726
children,
1573215727
void 0,
@@ -17750,14 +17745,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1775017745
};
1775117746
var isomorphicReactPackageVersion$jscomp$inline_2112 = React.version;
1775217747
if (
17753-
"19.2.0-native-fb-4a702865-20250507" !==
17748+
"19.2.0-native-fb-4206fe49-20250507" !==
1775417749
isomorphicReactPackageVersion$jscomp$inline_2112
1775517750
)
1775617751
throw Error(
1775717752
formatProdErrorMessage(
1775817753
527,
1775917754
isomorphicReactPackageVersion$jscomp$inline_2112,
17760-
"19.2.0-native-fb-4a702865-20250507"
17755+
"19.2.0-native-fb-4206fe49-20250507"
1776117756
)
1776217757
);
1776317758
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17779,10 +17774,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1777917774
};
1778017775
var internals$jscomp$inline_2119 = {
1778117776
bundleType: 0,
17782-
version: "19.2.0-native-fb-4a702865-20250507",
17777+
version: "19.2.0-native-fb-4206fe49-20250507",
1778317778
rendererPackageName: "react-dom",
1778417779
currentDispatcherRef: ReactSharedInternals,
17785-
reconcilerVersion: "19.2.0-native-fb-4a702865-20250507",
17780+
reconcilerVersion: "19.2.0-native-fb-4206fe49-20250507",
1778617781
getLaneLabelMap: function () {
1778717782
for (
1778817783
var map = new Map(), lane = 1, index$309 = 0;
@@ -17901,4 +17896,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1790117896
listenToAllSupportedEvents(container);
1790217897
return new ReactDOMHydrationRoot(initialChildren);
1790317898
};
17904-
exports.version = "19.2.0-native-fb-4a702865-20250507";
17899+
exports.version = "19.2.0-native-fb-4206fe49-20250507";

0 commit comments

Comments
 (0)