Skip to content

Commit 859a230

Browse files
committed
fix: add a svelte tick before attempting to add tabindex to list element
1 parent d617f97 commit 859a230

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/list/src/Item.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
<script lang="ts">
6868
import type { SvelteComponent } from 'svelte';
69-
import { onMount, onDestroy, getContext, setContext } from 'svelte';
69+
import { onMount, onDestroy, getContext, setContext, tick } from 'svelte';
7070
import { get_current_component } from 'svelte/internal';
7171
import type {
7272
SMUICheckboxInputAccessor,
@@ -179,7 +179,7 @@
179179
// Reset separator context, because we aren't directly under a list anymore.
180180
setContext('SMUI:separator:context', undefined);
181181
182-
onMount(() => {
182+
onMount(async () => {
183183
// Tabindex needs to be '0' if this is the first non-disabled list item, and
184184
// no other item is selected.
185185
@@ -200,6 +200,7 @@
200200
if (first) {
201201
// This is first, so now set up a check that no other items are
202202
// selected.
203+
await tick();
203204
addTabindexIfNoItemsSelectedRaf = window.requestAnimationFrame(
204205
addTabindexIfNoItemsSelected
205206
);

0 commit comments

Comments
 (0)