Skip to content

Commit

Permalink
fix: add a waiting period before submitting from markdown editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinderVosDeWael committed Jul 24, 2024
1 parent 68cf0c0 commit d5b82be
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib/components/ModalMarkdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
let replacementTags: string[] = []
let warningTags: string[] = []
let isLoading = false
function onSubmit(event: Event) {
event.preventDefault()
if ($modalStore[0].response) {
$modalStore[0].response({ value: text })
}
modalStore.close()
isLoading = true
// Text can take a moment to update, so we'll wait a bit before closing the modal.
setTimeout(() => {
if ($modalStore[0].response) {
$modalStore[0].response({ value: text })
}
modalStore.close()
}, 1000)
}
function detectTags(text: string, regex: RegExp) {
Expand Down Expand Up @@ -86,6 +92,6 @@
</div>
</div>

<button class="btn variant-filled-primary" on:click={onSubmit}>Save</button>
<button disabled={isLoading} class="btn variant-filled-primary" on:click={onSubmit}>Save</button>
</div>
{/if}

0 comments on commit d5b82be

Please sign in to comment.