diff --git a/src/lib/components/Button.svelte b/src/lib/components/Button.svelte index 94abdb0..b7dc47e 100644 --- a/src/lib/components/Button.svelte +++ b/src/lib/components/Button.svelte @@ -9,6 +9,7 @@ export let disabled: boolean = false; export let focusOnMount: boolean = false; + export let focusedChild = false; export let type: 'primary' | 'secondary' | 'primary-dark' = 'primary'; export let confirmDanger = false; export let action: (() => Promise) | null = null; @@ -62,6 +63,7 @@ on:clickOrSelect={handleClickOrSelect} on:enter {focusOnMount} + {focusedChild} >
- + -
- -
+
@@ -97,13 +97,12 @@ {/if} - @@ -160,7 +159,7 @@ {#if empty || unchanged} - {:else} @@ -233,7 +232,7 @@ {#if empty || unchanged} - {:else} @@ -257,7 +256,7 @@ {#if empty || unchanged} - {:else} @@ -278,16 +277,21 @@

All Set!

-
Reiverr is now ready to use.
+
Reiverr is now ready to use.
- +
- + Done +
diff --git a/src/lib/selectable.ts b/src/lib/selectable.ts index 01a21ac..7cb25cd 100644 --- a/src/lib/selectable.ts +++ b/src/lib/selectable.ts @@ -580,6 +580,20 @@ export class Selectable { console.error('No html element found for', this); return; } + + if (this.makeFocusedChild) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + let el: Selectable = this; + let parent = el.parent; + + while (parent && !get(parent.hasFocusWithin)) { + console.log('setting parent focusIndex', parent, parent.children.indexOf(el)); + parent.focusIndex.update((prev) => parent?.children?.indexOf(el) || prev); + + el = parent; + parent = el.parent; + } + } } _unmountContainer() { @@ -744,18 +758,6 @@ export class Selectable { this.children.splice(index, 0, child); child.parent = this; - if (child.makeFocusedChild) { - let el = child; - let parent = el.parent; - - while (parent && !get(parent.hasFocusWithin)) { - parent.focusIndex.update((prev) => parent?.children?.indexOf(el) || prev); - - el = parent; - parent = el.parent; - } - } - return childToFocus; }