Browse Source

fix(gui): close dropdown only if clicked outside

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4957/head
Pranav C 2 years ago
parent
commit
3a92f2aff8
  1. 14
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 2
      packages/nc-gui/components/cell/SingleSelect.vue

14
packages/nc-gui/components/cell/MultiSelect.vue

@ -15,15 +15,15 @@ import {
extractSdkResponseErrorMsg, extractSdkResponseErrorMsg,
h, h,
inject, inject,
isDrawerOrModalExist,
onMounted, onMounted,
reactive, reactive,
ref, ref,
useEventListener,
useMetas, useMetas,
useProject, useProject,
useEventListener,
useRoles, useRoles,
useSelectedCellKeyupListener, useSelectedCellKeyupListener,
isDrawerOrModalExist,
watch, watch,
} from '#imports' } from '#imports'
import MdiCloseCircle from '~icons/mdi/close-circle' import MdiCloseCircle from '~icons/mdi/close-circle'
@ -286,10 +286,14 @@ onUnmounted(() => {
cellClickHook?.on(cellClickHookHandler) cellClickHook?.on(cellClickHookHandler)
}) })
const handleClose = (e: MouseEvent) => { const handleClose = (e: MouseEvent) => {
if (isOpen.value && aselect.value && !aselect.value.$el.contains(e.target)) { // close dropdown if clicked outside of dropdown
if (
isOpen.value &&
aselect.value &&
!aselect.value.$el.contains(e.target) &&
!document.querySelector('.nc-dropdown-multi-select-cell')?.contains(e.target as Node)
) {
isOpen.value = false isOpen.value = false
} }
} }

2
packages/nc-gui/components/cell/SingleSelect.vue

@ -224,6 +224,8 @@ onUnmounted(() => {
cellClickHook?.on(cellClickHookHandler) cellClickHook?.on(cellClickHookHandler)
}) })
const handleClose = (e: MouseEvent) => { const handleClose = (e: MouseEvent) => {
if (isOpen.value && aselect.value && !aselect.value.$el.contains(e.target)) { if (isOpen.value && aselect.value && !aselect.value.$el.contains(e.target)) {
isOpen.value = false isOpen.value = false

Loading…
Cancel
Save