You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -159,11 +159,19 @@ function Unstable_TrapFocus(props) {
154
+
155
+
// restoreLastFocus()
156
+
if (!disableRestoreFocus) {
157
+
- // In IE 11 it is possible for document.activeElement to be null resulting
158
+
- // in nodeToRestore.current being null.
159
+
- // Not all elements in IE 11 have a focus method.
160
+
- // Once IE 11 support is dropped the focus() call can be unconditional.
161
+
- if (nodeToRestore.current && nodeToRestore.current.focus) {
162
+
+ if (
163
+
+ // In IE 11 it is possible for document.activeElement to be null resulting
164
+
+ // in nodeToRestore.current being null.
165
+
+ nodeToRestore.current &&
166
+
+ // Not all elements in IE 11 have a focus method.
167
+
+ // Once IE 11 support is dropped the focus() call can be unconditional.
168
+
+ nodeToRestore.current.focus &&
169
+
+ // We actually only want a WeakRef to nodeToRestore.
170
+
+ // If it's already unmounted don't restore focus to it.
171
+
+ // Can't reproduce it on an isolated test but "should trap once the focus moves inside" failed due to interleaving restore logic from the previous test.
0 commit comments