Skip to content

Commit 5ddfb1d

Browse files
committed
show sending state
1 parent 30f0f1f commit 5ddfb1d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/components/SuggestionForm.svelte

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
let body = $state('')
88
let error = $state('')
99
let url = $state('')
10+
let sending = $state(false)
1011
1112
async function create_issue(e: SubmitEvent) {
1213
e.preventDefault()
1314
15+
sending = true
1416
error = ''
1517
url = ''
1618
@@ -30,6 +32,8 @@
3032
} catch (err) {
3133
console.error(err)
3234
error = 'Failed to fetch API'
35+
} finally {
36+
sending = false
3337
}
3438
}
3539
</script>
@@ -53,7 +57,13 @@
5357
<textarea id="body" bind:value={body} required></textarea>
5458
</div>
5559

56-
<button class="button">Submit</button>
60+
<button class="button" disabled={sending}>
61+
{#if sending}
62+
Submitting...
63+
{:else}
64+
Submit
65+
{/if}
66+
</button>
5767
</form>
5868

5969
{#if error}

0 commit comments

Comments
 (0)