diff --git a/src/events.ts b/src/events.ts index b1b366e..9ba691f 100644 --- a/src/events.ts +++ b/src/events.ts @@ -28,8 +28,8 @@ function trapFocus(e: KeyboardEvent) { const popoverEl = getState("popover")?.wrapper; const focusableEls = getFocusableElements([ - ...(activeElement ? [activeElement] : []), ...(popoverEl ? [popoverEl] : []), + ...(activeElement ? [activeElement] : []), ]); const firstFocusableEl = focusableEls[0]; diff --git a/src/popover.ts b/src/popover.ts index 4d103ae..9f0b35a 100644 --- a/src/popover.ts +++ b/src/popover.ts @@ -224,7 +224,7 @@ export function renderPopover(element: Element, step: DriveStep) { // Focus on the first focusable element in active element or popover const isToDummyElement = element.classList.contains("driver-dummy-element"); - const focusableElement = getFocusableElements([...(isToDummyElement ? [] : [element]), popoverWrapper]); + const focusableElement = getFocusableElements([popoverWrapper, ...(isToDummyElement ? [] : [element])]); if (focusableElement.length > 0) { focusableElement[0].focus(); }