Skip to content

Commit

Permalink
fix: issue783 (#809)
Browse files Browse the repository at this point in the history
* fix: issue783

* fix: remove leftovers
  • Loading branch information
jjagielka committed May 29, 2023
1 parent cf1e551 commit 112bd25
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/utils/focusTrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const selectorTabbable = `

/** @type {import('svelte/action').Action} */
export default function focusTrap(node) {
const tabbable = Array.from(node.querySelectorAll(selectorTabbable));

/** @type {(e:KeyboardEvent)=>void} */
function handleFocusTrap(e) {
let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
Expand All @@ -22,6 +20,8 @@ export default function focusTrap(node) {
return;
}

const tabbable = Array.from(node.querySelectorAll(selectorTabbable));

let index = tabbable.indexOf(document.activeElement ?? node);
if (index === -1 && e.shiftKey) index = 0;
index += tabbable.length + (e.shiftKey ? -1 : 1);
Expand Down

2 comments on commit 112bd25

@vercel
Copy link

@vercel vercel bot commented on 112bd25 May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 112bd25 May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.