Skip to content

Commit

Permalink
fix(switch): focus
Browse files Browse the repository at this point in the history
  • Loading branch information
koory1st committed Feb 26, 2024
1 parent 0d22ad9 commit 992d62c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
5 changes: 5 additions & 0 deletions packages/switch/src/lib/switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
export let tabindex;
export let beforeChange = null;
export let width = null;
export function focus() {
input.focus();
}
$: size = size || getContext('svel-size');
$: isControlled = value !== false;
$: actualValue = value;
Expand Down
27 changes: 16 additions & 11 deletions packages/switch/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
}, 1000);
});
};
let focus;
</script>

<!--<SvelSwitch bind:value />-->
Expand Down Expand Up @@ -69,14 +71,17 @@
<!--<SvelSwitch beforeChange={beforeChange1} bind:value loading={loading1} />-->
<!--<SvelSwitch beforeChange={beforeChange2} bind:value={value2} loading={loading2} />-->

<div />
<SvelSwitch bind:value>
<View slot="activeActionIcon" />
<Hide slot="inactiveActionIcon" />
</SvelSwitch>

<div />
<SvelSwitch bind:value>
<span slot="activeActionIcon">T</span>
<span slot="inactiveActionIcon">F</span>
</SvelSwitch>
<!--<div />-->
<!--<SvelSwitch bind:value>-->
<!-- <View slot="activeActionIcon" />-->
<!-- <Hide slot="inactiveActionIcon" />-->
<!--</SvelSwitch>-->

<!--<div />-->
<!--<SvelSwitch bind:value>-->
<!-- <span slot="activeActionIcon">T</span>-->
<!-- <span slot="inactiveActionIcon">F</span>-->
<!--</SvelSwitch>-->

<!--<SvelSwitch bind:focus bind:value />-->
<!--<button on:click={() => focus()}>focus</button>-->

0 comments on commit 992d62c

Please sign in to comment.