Skip to content

Commit d65fb06

Browse files
committed
fix: restore selection should consider the window of the container (#30951)
## Summary Fixes #30864 Before this PR the active elemen was always taken from the global `window`. This is incorrect if the renderer is in one window rendering into a container element in another window. The changes in this PR adds another code branch to use a `defaultView` of the container element if it exists so that `restoreSelection` after a commit will actually restore to the correct window. ## How did you test this change? I patched these changes to the repro repo in the linked issue #39864 https://github.com/ling1726/react-child-window-focus-repro/blob/master/patches/react-dom%2B18.3.1.patch. I followed the same repro steps in the linked issue and and could not repro the reported problem. Attaching screen recordings below: Before ![focus repro](https://github.com/user-attachments/assets/81c4b4f9-08b5-4356-8251-49b909771f3f) After ![after](https://github.com/user-attachments/assets/84883032-5558-4650-9b9a-bd4d5fd9cb13) DiffTrain build for [d9c4920](d9c4920)
1 parent 9d3ed27 commit d65fb06

34 files changed

+4044
-3903
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d3d4d3a46b014ab0f6edc443c19fcdba09105f20
1+
d9c4920e8b3fff3d3da24d14adf7ac884aee55b2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d3d4d3a46b014ab0f6edc443c19fcdba09105f20
1+
d9c4920e8b3fff3d3da24d14adf7ac884aee55b2

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ __DEV__ &&
20012001
exports.useTransition = function () {
20022002
return resolveDispatcher().useTransition();
20032003
};
2004-
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";
2004+
exports.version = "19.0.0-www-classic-d9c4920e-20240913";
20052005
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
20062006
"function" ===
20072007
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ __DEV__ &&
19811981
exports.useTransition = function () {
19821982
return resolveDispatcher().useTransition();
19831983
};
1984-
exports.version = "19.0.0-www-modern-d3d4d3a4-20240913";
1984+
exports.version = "19.0.0-www-modern-d9c4920e-20240913";
19851985
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19861986
"function" ===
19871987
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";
668+
exports.version = "19.0.0-www-classic-d9c4920e-20240913";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-modern-d3d4d3a4-20240913";
668+
exports.version = "19.0.0-www-modern-d9c4920e-20240913";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";
672+
exports.version = "19.0.0-www-classic-d9c4920e-20240913";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-modern-d3d4d3a4-20240913";
672+
exports.version = "19.0.0-www-modern-d9c4920e-20240913";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17112,11 +17112,11 @@ __DEV__ &&
1711217112
(function () {
1711317113
var internals = {
1711417114
bundleType: 1,
17115-
version: "19.0.0-www-classic-d3d4d3a4-20240913",
17115+
version: "19.0.0-www-classic-d9c4920e-20240913",
1711617116
rendererPackageName: "react-art",
1711717117
currentDispatcherRef: ReactSharedInternals,
1711817118
findFiberByHostInstance: getInstanceFromNode,
17119-
reconcilerVersion: "19.0.0-www-classic-d3d4d3a4-20240913"
17119+
reconcilerVersion: "19.0.0-www-classic-d9c4920e-20240913"
1712017120
};
1712117121
internals.overrideHookState = overrideHookState;
1712217122
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -17150,7 +17150,7 @@ __DEV__ &&
1715017150
exports.Shape = Shape;
1715117151
exports.Surface = Surface;
1715217152
exports.Text = Text;
17153-
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";
17153+
exports.version = "19.0.0-www-classic-d9c4920e-20240913";
1715417154
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1715517155
"function" ===
1715617156
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16558,11 +16558,11 @@ __DEV__ &&
1655816558
(function () {
1655916559
var internals = {
1656016560
bundleType: 1,
16561-
version: "19.0.0-www-modern-d3d4d3a4-20240913",
16561+
version: "19.0.0-www-modern-d9c4920e-20240913",
1656216562
rendererPackageName: "react-art",
1656316563
currentDispatcherRef: ReactSharedInternals,
1656416564
findFiberByHostInstance: getInstanceFromNode,
16565-
reconcilerVersion: "19.0.0-www-modern-d3d4d3a4-20240913"
16565+
reconcilerVersion: "19.0.0-www-modern-d9c4920e-20240913"
1656616566
};
1656716567
internals.overrideHookState = overrideHookState;
1656816568
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16596,7 +16596,7 @@ __DEV__ &&
1659616596
exports.Shape = Shape;
1659716597
exports.Surface = Surface;
1659816598
exports.Text = Text;
16599-
exports.version = "19.0.0-www-modern-d3d4d3a4-20240913";
16599+
exports.version = "19.0.0-www-modern-d9c4920e-20240913";
1660016600
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1660116601
"function" ===
1660216602
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)