Skip to content

Commit 10184f8

Browse files
tutorial step 7/8: improve a11y, teach better practices (#1592)
* tutorial step 7: improve a11y, teach better practices it's easier, and more accessible, to handle a single submit event on a form than it is to handle both click on button and enter keydown on input * use form and submit handler in tutorial step 8 Co-authored-by: Natalia Tepluhina <[email protected]>
1 parent 840abfb commit 10184f8

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/tutorial/src/step-7/App/template.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
<input v-model="newTodo" @keyup.enter="addTodo">
2-
<button @click="addTodo">Add Todo</button>
1+
<form @submit.prevent="addTodo">
2+
<input v-model="newTodo">
3+
<button>Add Todo</button>
4+
</form>
35
<ul>
46
<li v-for="todo in todos" :key="todo.id">
57
{{ todo.text }}

src/tutorial/src/step-8/App/template.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
<input v-model="newTodo" @keyup.enter="addTodo">
2-
<button @click="addTodo">Add Todo</button>
1+
<form @submit.prevent="addTodo">
2+
<input v-model="newTodo" />
3+
<button>Add Todo</button>
4+
</form>
35
<ul>
46
<li v-for="todo in todos" :key="todo.id">
57
<input type="checkbox" v-model="todo.done">

src/tutorial/src/step-8/_hint/App/template.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
<input v-model="newTodo" @keyup.enter="addTodo">
2-
<button @click="addTodo">Add Todo</button>
1+
<form @submit.prevent="addTodo">
2+
<input v-model="newTodo" />
3+
<button>Add Todo</button>
4+
</form>
35
<ul>
46
<li v-for="todo in filteredTodos" :key="todo.id">
57
<input type="checkbox" v-model="todo.done">

0 commit comments

Comments
 (0)