Workaround tabIndex=-1 added to document body by SvelteKit

This ends up producing a lot of extra focus events that normally would not exist.

Fixes #36
Fixes #39
This commit is contained in:
Ryan Gossiaux
2022-01-21 16:17:16 -08:00
parent ac1f86ac15
commit bc809ef590
4 changed files with 19 additions and 3 deletions

View File

@@ -137,7 +137,11 @@
onMount(() => registerPopover?.(registerBag));
// Handle focus out
function handleFocus() {
function handleFocus(event: FocusEvent) {
if (event.target === window.document.body) {
// Workaround for a SvelteKit issue: https://github.com/sveltejs/kit/issues/3501
return;
}
if (popoverState !== PopoverStates.Open) return;
if (isFocusWithinPopoverGroup()) return;
if (!button) return;