Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/lib/components/modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
export let error: string = null;
export let closable = true;

let alert: HTMLElement;
const dispatch = createEventDispatcher();
const transitionFly: FlyParams = {
duration: 150,
Expand Down Expand Up @@ -48,6 +49,10 @@
document.body.classList.remove('u-overflow-hidden');
}
}

$: if (error) {
alert?.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest' });
}
</script>

<svelte:window on:keydown={handleKeydown} />
Expand Down Expand Up @@ -81,14 +86,16 @@
</header>
<div class="modal-content">
{#if error}
<Alert
dismissible
type="warning"
on:dismiss={() => {
error = null;
}}>
{error}
</Alert>
<div bind:this={alert}>
<Alert
dismissible
type="warning"
on:dismiss={() => {
error = null;
}}>
{error}
</Alert>
</div>
{/if}
<slot />
</div>
Expand Down