Skip to content

Commit

Permalink
[fix] Disable delete button while waiting for API response (#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ric2b authored Aug 12, 2021
1 parent c3ca3fb commit d6a50b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wicked-humans-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Disable delete button while waiting for API response
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
created_at: Date;
text: string;
done: boolean;
pending_delete: boolean;
};
export let todos: Todo[];
Expand Down Expand Up @@ -105,12 +106,13 @@
action="/todos/{todo.uid}.json?_method=delete"
method="post"
use:enhance={{
pending: () => (todo.pending_delete = true),
result: () => {
todos = todos.filter((t) => t.uid !== todo.uid);
}
}}
>
<button class="delete" aria-label="Delete todo" />
<button class="delete" aria-label="Delete todo" disabled={todo.pending_delete} />
</form>
</div>
{/each}
Expand Down

0 comments on commit d6a50b8

Please sign in to comment.