From 3405ac3cc1ab1d5c4bc4c6e02b0313474b2db0ff Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sun, 17 Jul 2022 20:52:35 +0200 Subject: [PATCH] Create item on enter. --- src/views/List.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/views/List.vue b/src/views/List.vue index ff65f5f..234a79a 100644 --- a/src/views/List.vue +++ b/src/views/List.vue @@ -103,11 +103,15 @@ export default { recopyItemsObject: function () { this.searchResults = this.initialItems.map(x => ({...x})); }, - searchItem: function () { - if (this.searchQ.length > 0) { - this.searchResults = this.searchResults.filter(i => i.content.toLowerCase().indexOf(this.searchQ.toLowerCase()) >= 0) + searchItem: function (e) { + if (e.key === 'Enter') { + this.createItem(); } else { - this.recopyItemsObject(); + if (this.searchQ.length > 0) { + this.searchResults = this.searchResults.filter(i => i.content.toLowerCase().indexOf(this.searchQ.toLowerCase()) >= 0) + } else { + this.recopyItemsObject(); + } } }, addItem: function (item) {