Skip to content

Commit 2d82059

Browse files
committed
Focus on popover first then element
1 parent 6bf3ab4 commit 2d82059

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function trapFocus(e: KeyboardEvent) {
2828
const popoverEl = getState("popover")?.wrapper;
2929

3030
const focusableEls = getFocusableElements([
31-
...(activeElement ? [activeElement] : []),
3231
...(popoverEl ? [popoverEl] : []),
32+
...(activeElement ? [activeElement] : []),
3333
]);
3434

3535
const firstFocusableEl = focusableEls[0];

src/popover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export function renderPopover(element: Element, step: DriveStep) {
224224

225225
// Focus on the first focusable element in active element or popover
226226
const isToDummyElement = element.classList.contains("driver-dummy-element");
227-
const focusableElement = getFocusableElements([...(isToDummyElement ? [] : [element]), popoverWrapper]);
227+
const focusableElement = getFocusableElements([popoverWrapper, ...(isToDummyElement ? [] : [element])]);
228228
if (focusableElement.length > 0) {
229229
focusableElement[0].focus();
230230
}

0 commit comments

Comments
 (0)