11: Cancel Edit Todo

Let's work to cancel edit mode by pressing ESC key.

  1. Add keyup event listener to <input> of edit todo by x-on:keyup.esc directive. It calls cancelEdit invocation on escape-key only.

<body>
  <section class="todoapp"


      doneEdit (_, payload, meta) {

      },
      cancelEdit (_, payload, meta) {
        this.editingTodoIndex = -1
      },
    }"
  ::>

    <section class="main">

      <ul class="todo-list"
        x-each="todo, index in todos"
      >


          <input class="edit"
            :value="todo.title"
            @change="doneEdit({index})"
            @keyup.esc="cancelEdit"
          >
        </li>
      </ul>
    </section>

  </section>
</body>
</html>