button always autofocusses, allows us to simplify

pull/8200/head
Simon H 4 years ago committed by GitHub
parent ea19719b78
commit 5e7219ba24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,21 +1,14 @@
<script> <script>
import Modal from './Modal.svelte'; import Modal from './Modal.svelte';
let button; // HTMLButtonElement
let showModal = false; let showModal = false;
</script> </script>
<button bind:this={button} on:click={() => (showModal = true)}> <button on:click={() => (showModal = true)}>
show modal show modal
</button> </button>
<Modal <Modal bind:showModal>
{showModal}
on:close={() => {
showModal = false;
button.focus();
}}
>
<h2 slot="header"> <h2 slot="header">
modal modal
<small><em>adjective</em> mod·al \ˈmō-dəl\</small> <small><em>adjective</em> mod·al \ˈmō-dəl\</small>

@ -7,7 +7,11 @@
</script> </script>
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
<dialog bind:this={dialog} on:close on:click|self={() => dialog.close()}> <dialog
bind:this={dialog}
on:close={() => (showModal = false)}
on:click|self={() => dialog.close()}
>
<div on:click|stopPropagation> <div on:click|stopPropagation>
<slot name="header" /> <slot name="header" />
<hr /> <hr />

Loading…
Cancel
Save