Skip to content

Commit 432d13b

Browse files
author
Llorenç
committed
Do not use tabindex
1 parent 2677983 commit 432d13b

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

  • src/frontend/src/routes/(new-styling)/recovery-phrase

src/frontend/src/routes/(new-styling)/recovery-phrase/+page.svelte

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import { t } from "$lib/stores/locale.store";
55
import { nonNullish } from "@dfinity/utils";
66
7-
const handleKeyDownInput = (
8-
event: KeyboardEvent,
9-
currentTabIndex: number,
10-
) => {
7+
let inputContainerRef: HTMLDivElement | null = null;
8+
9+
const handleKeyDownInput = (event: KeyboardEvent, currentIndex: number) => {
1110
if (event.key === "Enter" || event.key === " ") {
1211
event.preventDefault();
13-
const nextTabIndex = currentTabIndex + 1;
14-
const nextElement = document.querySelector(
15-
`[tabindex="${nextTabIndex}"]`,
16-
) as HTMLElement;
12+
const nextTabIndex = currentIndex + 1;
13+
const inputElements = inputContainerRef?.querySelectorAll(
14+
"input",
15+
) as NodeListOf<HTMLInputElement>;
16+
const nextElement = inputElements?.[nextTabIndex];
1717
if (nonNullish(nextElement)) {
1818
nextElement.focus();
1919
}
@@ -36,15 +36,14 @@
3636
</p>
3737
</div>
3838
<div class="flex flex-col gap-3">
39-
<div class="grid grid-cols-3 gap-3">
39+
<div class="grid grid-cols-3 gap-3" bind:this={inputContainerRef}>
4040
{#each Array.from({ length: 24 }) as _, i}
4141
<label class="relative h-8">
4242
<!-- Text input -->
4343
<input
4444
type="text"
4545
id={`recovery-phrase-${i}`}
46-
tabindex={i + 1}
47-
on:keydown={(e) => handleKeyDownInput(e, i + 1)}
46+
on:keydown={(e) => handleKeyDownInput(e, i)}
4847
class="peer text-text-primary ring-border-secondary focus:ring-border-brand h-8 w-full rounded-full border-none bg-transparent pl-10 text-base ring outline-none ring-inset focus:ring-2"
4948
/>
5049
<!-- Left slot -->
@@ -58,15 +57,11 @@
5857
{/each}
5958
</div>
6059
<div class="flex flex-row gap-2">
61-
<Button class="w-full" variant="tertiary" tabindex={25}
62-
>{$t`Show all`}</Button
63-
>
64-
<Button class="w-full" variant="tertiary" tabindex={26}
65-
>{$t`Clear all`}</Button
66-
>
60+
<Button class="w-full" variant="tertiary">{$t`Show all`}</Button>
61+
<Button class="w-full" variant="tertiary">{$t`Clear all`}</Button>
6762
</div>
6863
</div>
69-
<Button size="xl" variant="secondary" tabindex={27}>{$t`Cancel`}</Button>
64+
<Button size="xl" variant="secondary">{$t`Cancel`}</Button>
7065
</div>
7166
</AuthPanel>
7267
</div>

0 commit comments

Comments
 (0)