From 7ae97d551fb920060c36392e2e5128893b45d7aa Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 27 Jun 2023 18:02:48 +0300 Subject: [PATCH] feat: avoid click outside event on scrollbar click Signed-off-by: mertmit --- .../nc-gui/components/smartsheet/Grid.vue | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 018f533d88..d1b2c0af8d 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -99,6 +99,8 @@ const contextMenu = computed({ }) const contextMenuClosing = ref(false) +const scrolling = ref(false) + const bulkUpdateDlg = ref(false) const routeQuery = $computed(() => route.query as Record) @@ -660,6 +662,11 @@ const smartTable = ref(null) /** On clicking outside of table reset active cell */ onClickOutside(tableBodyEl, (e) => { + // do nothing if mousedown on the scrollbar (scrolling) + if (scrolling.value) { + return + } + // do nothing if context menu was open if (contextMenu.value) return @@ -936,6 +943,19 @@ watch( useEventListener(gridWrapper, 'scroll', () => { refreshFillHandle() }) + +useEventListener(document, 'mousedown', (e) => { + if (e.offsetX > (e.target as HTMLElement)?.clientWidth || e.offsetY > (e.target as HTMLElement)?.clientHeight) { + scrolling.value = true + } +}) + +useEventListener(document, 'mouseup', () => { + // wait for click event to finish before setting scrolling to false + setTimeout(() => { + scrolling.value = false + }, 100) +})