From 3dbd36eef7669f6cc872106773c74abed8452f99 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 3 Jun 2021 22:58:47 +0200 Subject: [PATCH] Move creation of new items to the bottom of the multiselect list --- src/components/input/multiselect.vue | 61 +++++++++----------- src/components/tasks/partials/editLabels.vue | 1 + 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/components/input/multiselect.vue b/src/components/input/multiselect.vue index 2bb52051..f0db907c 100644 --- a/src/components/input/multiselect.vue +++ b/src/components/input/multiselect.vue @@ -26,7 +26,7 @@ @keyup="search" @keyup.enter.exact.prevent="() => createOrSelectOnEnter()" :placeholder="placeholder" - @keydown.down.exact.prevent="() => preSelect(0, true)" + @keydown.down.exact.prevent="() => preSelect(0)" ref="searchInput" @focus="() => showSearchResults = true" /> @@ -35,27 +35,6 @@
- - + +
@@ -202,14 +202,14 @@ export default { }, computed: { searchResultsVisible() { - if(this.query === '' && !this.showEmpty) { + if (this.query === '' && !this.showEmpty) { return false } return this.showSearchResults && ( - (this.filteredSearchResults.length > 0) || - (this.creatable && this.query !== '') - ) + (this.filteredSearchResults.length > 0) || + (this.creatable && this.query !== '') + ) }, creatableAvailable() { return this.creatable && this.query !== '' && !this.filteredSearchResults.some(elem => { @@ -295,13 +295,8 @@ export default { this.query = this.label !== '' ? object[this.label] : object }, - preSelect(index, lookForCreatable = false) { - - if (index === 0 && this.creatable && lookForCreatable) { - index = -1 - } - - if (index < -1) { + preSelect(index) { + if (index < 0) { this.$refs.searchInput.focus() return } diff --git a/src/components/tasks/partials/editLabels.vue b/src/components/tasks/partials/editLabels.vue index a40f2113..5c03449c 100644 --- a/src/components/tasks/partials/editLabels.vue +++ b/src/components/tasks/partials/editLabels.vue @@ -11,6 +11,7 @@ @create="createAndAddLabel" create-placeholder="Add this as new label" v-model="labels" + :search-delay="10" >