mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
d65fb06955e9f32e6a40d1c7177d77893dff95b9
## 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

After

DiffTrain build for [d9c4920e8b](https://github.com/facebook/react/commit/d9c4920e8b3fff3d3da24d14adf7ac884aee55b2)
Please do not delete this branch
Description
Languages
JavaScript
67.1%
TypeScript
29.4%
HTML
1.5%
CSS
1.1%
C++
0.6%
Other
0.2%