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:
@@ -109,6 +109,10 @@
|
|||||||
|
|
||||||
// Prevent programmatically escaping
|
// Prevent programmatically escaping
|
||||||
function handleWindowFocus(event: FocusEvent) {
|
function handleWindowFocus(event: FocusEvent) {
|
||||||
|
if (event.target === window.document.body) {
|
||||||
|
// Workaround for a SvelteKit issue: https://github.com/sveltejs/kit/issues/3501
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
if (containers.size !== 1) return;
|
if (containers.size !== 1) return;
|
||||||
if (destroying) return;
|
if (destroying) return;
|
||||||
|
|||||||
@@ -137,7 +137,11 @@
|
|||||||
onMount(() => registerPopover?.(registerBag));
|
onMount(() => registerPopover?.(registerBag));
|
||||||
|
|
||||||
// Handle focus out
|
// 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 (popoverState !== PopoverStates.Open) return;
|
||||||
if (isFocusWithinPopoverGroup()) return;
|
if (isFocusWithinPopoverGroup()) return;
|
||||||
if (!button) return;
|
if (!button) return;
|
||||||
|
|||||||
@@ -42,7 +42,11 @@
|
|||||||
let previousActiveElementRef: Element | null =
|
let previousActiveElementRef: Element | null =
|
||||||
typeof window === "undefined" ? null : document.activeElement;
|
typeof window === "undefined" ? null : document.activeElement;
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
previousActiveElementRef = activeElementRef;
|
previousActiveElementRef = activeElementRef;
|
||||||
activeElementRef = document.activeElement;
|
activeElementRef = document.activeElement;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 (!focus) return;
|
if (!focus) return;
|
||||||
if ($api.popoverState !== PopoverStates.Open) return;
|
if ($api.popoverState !== PopoverStates.Open) return;
|
||||||
if (!$panelStore) return;
|
if (!$panelStore) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user