File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed
packages/compose/src/hooks/use-focus-return Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -48,21 +48,13 @@ function useFocusReturn( onFocusReturn ) {
4848 return ;
4949 }
5050
51- /** @type {any } */
52- const activeElement = node . ownerDocument . activeElement ;
51+ const activeDocument =
52+ node . ownerDocument . activeElement instanceof
53+ window . HTMLIFrameElement
54+ ? node . ownerDocument . activeElement . contentDocument
55+ : node . ownerDocument ;
5356
54- // If the activeElement is an iframe, we need to get the active element within the iframe.
55- // Otherwise, focus from items within the iframed canvas will get sent to the iframe itself,
56- // not the active element within the iframe.
57- if (
58- activeElement ?. tagName === 'IFRAME' &&
59- activeElement . contentDocument ?. activeElement
60- ) {
61- focusedBeforeMount . current =
62- activeElement . contentDocument . activeElement ;
63- } else {
64- focusedBeforeMount . current = activeElement ;
65- }
57+ focusedBeforeMount . current = activeDocument ?. activeElement ?? null ;
6658 } else if ( focusedBeforeMount . current ) {
6759 const isFocused = ref . current ?. contains (
6860 ref . current ?. ownerDocument . activeElement
You can’t perform that action at this time.
0 commit comments