Close context menu when using mouse wheel or menu touching scrollbars
This commit is contained in:
parent
901ba53630
commit
7486d3dde0
|
@ -12,6 +12,7 @@
|
|||
bounds,
|
||||
hoveredRowId,
|
||||
hiddenColumnsWidth,
|
||||
menu,
|
||||
} = getContext("grid")
|
||||
|
||||
export let scrollVertically = false
|
||||
|
@ -30,6 +31,11 @@
|
|||
const handleWheel = e => {
|
||||
e.preventDefault()
|
||||
debouncedHandleWheel(e.deltaX, e.deltaY, e.clientY)
|
||||
|
||||
// If a context menu was visible, hide it
|
||||
if ($menu.visible) {
|
||||
menu.actions.close()
|
||||
}
|
||||
}
|
||||
const debouncedHandleWheel = domDebounce((deltaX, deltaY, clientY) => {
|
||||
const { top, left } = $scroll
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
scrollTop,
|
||||
height,
|
||||
isDragging,
|
||||
menu,
|
||||
} = getContext("grid")
|
||||
|
||||
// State for dragging bars
|
||||
|
@ -45,6 +46,13 @@
|
|||
$: availWidth = renderWidth - barWidth
|
||||
$: barLeft = ScrollBarSize + availWidth * ($scrollLeft / $maxScrollLeft)
|
||||
|
||||
// Helper to close the context menu if it's open
|
||||
const closeMenu = () => {
|
||||
if ($menu.visible) {
|
||||
menu.actions.close()
|
||||
}
|
||||
}
|
||||
|
||||
// V scrollbar drag handlers
|
||||
const startVDragging = e => {
|
||||
e.preventDefault()
|
||||
|
@ -53,6 +61,7 @@
|
|||
document.addEventListener("mousemove", moveVDragging)
|
||||
document.addEventListener("mouseup", stopVDragging)
|
||||
isDraggingV = true
|
||||
closeMenu()
|
||||
}
|
||||
const moveVDragging = domDebounce(e => {
|
||||
const delta = e.clientY - initialMouse
|
||||
|
@ -77,6 +86,7 @@
|
|||
document.addEventListener("mousemove", moveHDragging)
|
||||
document.addEventListener("mouseup", stopHDragging)
|
||||
isDraggingH = true
|
||||
closeMenu()
|
||||
}
|
||||
const moveHDragging = domDebounce(e => {
|
||||
const delta = e.clientX - initialMouse
|
||||
|
|
Loading…
Reference in New Issue