Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
nuxodin committed Mar 14, 2023
1 parent 086c55a commit 56804af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion focusgroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ document.addEventListener('keydown', e => {
if (!direction) return;

//const focusable = [...parent.querySelectorAll(':is(a[href], button, input, select, textarea, [contenteditable], [tabindex]:not([tabindex="-1"]))')];
const focusable = [...parent.querySelectorAll(':is(a[href], button, input, select, textarea, [contenteditable], [tabindex])')];
const selector = ':is(a[href], button, input, select, textarea, [contenteditable], [tabindex])';
const focusable = [...parent.querySelectorAll(selector)].filter(el => !el.disabled);
if (focusable.length < 2) return;

const index = focusable.indexOf(target);
Expand Down
1 change: 1 addition & 0 deletions tests/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h2>u1-focusgroup</h2>

<div style="display:flex; gap:1rem" u1-focusgroup>
<button>press left or up key to focus the previous button</button>
<button disabled>disabled</button>
<button>press right or down key to focus the next button</button>
</div>
</section>
Expand Down

0 comments on commit 56804af

Please sign in to comment.