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
Avoid restoring focus when clicking on focusable element outside Popover
Fix an issue where clicking on a focusable element outside of an open popover,
other than the previously focused element, would cause focus to be reverted back
to the previously focused element.
When native popovers are used, they handle focus restoration for us [^1], so we
don't need to do anything when the popover is closed. Setting
`restoreFocusOnClose` to `false` didn't actually work in this case. When
non-native popovers are used, focus reverts to `document.body` when the popover
is hidden, unless the user clicked on a different focusable element outside the
popover. Only when it has reverted to `document.body` do we want to restore
focus.
Fixes#1906
[^1]: See `focusPreviousElement` references in https://html.spec.whatwg.org/multipage/popover.html#dom-hidepopover
0 commit comments