From f59ee815860a114503a165d3a34fd4a7862af3b7 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 29 Oct 2022 01:40:24 +0530 Subject: [PATCH] feat: open select options on enter key press Signed-off-by: Pranav C --- .../nc-gui/components/cell/MultiSelect.vue | 32 ++++++++++++++----- .../nc-gui/components/cell/SingleSelect.vue | 3 ++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/components/cell/MultiSelect.vue b/packages/nc-gui/components/cell/MultiSelect.vue index 9fe19858b0..d57f4490da 100644 --- a/packages/nc-gui/components/cell/MultiSelect.vue +++ b/packages/nc-gui/components/cell/MultiSelect.vue @@ -16,6 +16,7 @@ import { useProject, watch, } from '#imports' +import { useSelectedCellKeyupListener } from '~/composables/useSelectedCellKeyupListener' import MdiCloseCircle from '~icons/mdi/close-circle' interface Props { @@ -73,13 +74,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 : [], @@ -93,9 +94,13 @@ const handleKeys = (e: KeyboardEvent) => { break case 'ArrowDown': case 'ArrowUp': + e.stopPropagation() + break case 'Enter': + isOpen.value = true e.stopPropagation() break + } } @@ -135,11 +140,17 @@ watch( watch(isOpen, (n, _o) => { if (!n) aselect.value?.$el.blur() }) + +useEventListener(document, 'keydown', (e) => { + if (active.value && e.key === 'Enter') { + isOpen.value = true + } +})