|
66 | 66 |
|
67 | 67 | <script lang="ts">
|
68 | 68 | import type { SvelteComponent } from 'svelte';
|
69 |
| - import { onMount, onDestroy, getContext, setContext, tick } from 'svelte'; |
| 69 | + import { onMount, onDestroy, getContext, setContext } from 'svelte'; |
70 | 70 | import { get_current_component } from 'svelte/internal';
|
71 | 71 | import type {
|
72 | 72 | SMUICheckboxInputAccessor,
|
|
179 | 179 | // Reset separator context, because we aren't directly under a list anymore.
|
180 | 180 | setContext('SMUI:separator:context', undefined);
|
181 | 181 |
|
182 |
| - onMount(async () => { |
| 182 | + onMount(() => { |
183 | 183 | // Tabindex needs to be '0' if this is the first non-disabled list item, and
|
184 | 184 | // no other item is selected.
|
185 | 185 |
|
186 | 186 | if (!selected && !nonInteractive) {
|
187 | 187 | let first = true;
|
188 |
| - let el = element; |
| 188 | + let el = element.getElement(); |
189 | 189 | while (el.previousSibling) {
|
190 | 190 | el = el.previousSibling;
|
191 | 191 | if (
|
|
200 | 200 | if (first) {
|
201 | 201 | // This is first, so now set up a check that no other items are
|
202 | 202 | // selected.
|
203 |
| - await tick(); |
204 |
| - addTabindexIfNoItemsSelectedRaf = window.requestAnimationFrame( |
205 |
| - addTabindexIfNoItemsSelected |
| 203 | + addTabindexIfNoItemsSelectedRaf = window.requestAnimationFrame(() => |
| 204 | + addTabindexIfNoItemsSelected(el) |
206 | 205 | );
|
207 | 206 | }
|
208 | 207 | }
|
|
336 | 335 | }
|
337 | 336 | }
|
338 | 337 |
|
339 |
| - function addTabindexIfNoItemsSelected() { |
340 |
| - if (!element) { |
341 |
| - return; |
342 |
| - } |
343 |
| -
|
| 338 | + function addTabindexIfNoItemsSelected(el: HTMLElement) { |
344 | 339 | // Look through next siblings to see if none of them are selected.
|
345 | 340 | let noneSelected = true;
|
346 |
| - let el = element.getElement(); |
347 | 341 | while (el.nextElementSibling) {
|
348 | 342 | el = el.nextElementSibling as HTMLElement;
|
349 | 343 | if (
|
|
0 commit comments