From 26d7759c9e5523541a7f43ad6fb647aedb8f2069 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 21 Nov 2022 21:46:49 +0530 Subject: [PATCH] fix: clear icon in multi select Signed-off-by: Pranav C --- .../nc-gui/components/cell/MultiSelect.vue | 29 ++++++++++++++----- .../nc-gui/components/cell/SingleSelect.vue | 5 ++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/nc-gui/components/cell/MultiSelect.vue b/packages/nc-gui/components/cell/MultiSelect.vue index 971e190d78..19f7c2d51b 100644 --- a/packages/nc-gui/components/cell/MultiSelect.vue +++ b/packages/nc-gui/components/cell/MultiSelect.vue @@ -95,7 +95,7 @@ const vModel = computed({ return selected }, set: (val) => { - if (isOptionMissing.value && val[val.length - 1] === searchVal.value) { + if (isOptionMissing.value && val.length && val[val.length - 1] === searchVal.value) { return addIfMissingAndSave() } emit('update:modelValue', val.length === 0 ? null : val.join(',')) @@ -107,13 +107,13 @@ const selectedTitles = computed(() => ? typeof modelValue === 'string' ? isMysql ? modelValue.split(',').sort((a, b) => { - const opa = options.value.find((el) => el.title === a) - const opb = options.value.find((el) => el.title === b) - if (opa && opb) { - return opa.order! - opb.order! - } - return 0 - }) + const opa = options.value.find((el) => el.title === a) + const opb = options.value.find((el) => el.title === b) + if (opa && opb) { + return opa.order! - opb.order! + } + return 0 + }) : modelValue.split(',') : modelValue : [], @@ -219,6 +219,17 @@ async function addIfMissingAndSave() { const search = () => { searchVal.value = aselect.value?.$el?.querySelector('.ant-select-selection-search-input')?.value } + +const onTagClick = (e: Event, onClose: Function) => { + // check clicked element is remove icon + if ( + (e.target as HTMLElement)?.classList.contains('ant-tag-close-icon') || + (e.target as HTMLElement)?.closest('.ant-tag-close-icon') + ) { + e.stopPropagation() + onClose() + } +}