Skip to content

Commit 3305123

Browse files
authored
Fix user comment bug (sveltejs#320)
Set the user comment string before clearing the input value.
1 parent 9aa5e28 commit 3305123

File tree

1 file changed

+1
-2
lines changed
  • content/tutorial/01-svelte/07-lifecycle/02-update/app-a/src/lib

1 file changed

+1
-2
lines changed

content/tutorial/01-svelte/07-lifecycle/02-update/app-a/src/lib/App.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
2828
async function handleKeydown(event) {
2929
if (event.key === 'Enter' && event.target.value) {
30-
event.target.value = '';
31-
3230
const comment = {
3331
author: 'user',
3432
text: event.target.value
@@ -39,6 +37,7 @@
3937
text: eliza.transform(comment.text)
4038
};
4139
40+
event.target.value = '';
4241
comments = [...comments, comment];
4342
4443
await pause(200 * (1 + Math.random()));

0 commit comments

Comments
 (0)