From c0779f1019a76fbc8d43d73fdf0fa6e5b02fb655 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Mon, 24 Jul 2023 00:32:23 +0100 Subject: [PATCH] Focus on popover first then element --- src/events.ts | 2 +- src/popover.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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(); }