Skip to content

Commit

Permalink
fix: cannot use middle mouse button to scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed May 9, 2024
1 parent 25be127 commit d0e7f4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/lib/components/modes/tablemode/TableMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,11 @@
}
function handleMouseDown(event: MouseEvent) {
// only handle when the left or right mouse button is pressed, not the middle mouse button (scroll wheel)
if (event.buttons !== 1 && event.buttons !== 2) {
return
}
const target = event.target as HTMLElement
const path = getDataPathFromTarget(target)
if (path) {
Expand Down
7 changes: 6 additions & 1 deletion src/lib/components/modes/treemode/JSONNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,15 @@
}
function handleMouseDown(event: MouseEvent & { currentTarget: EventTarget & HTMLDivElement }) {
// only handle when the left or right mouse button is pressed, not the middle mouse button (scroll wheel)
if (event.buttons !== 1 && event.buttons !== 2) {
return
}
// check if the mouse down is not happening in the key or value input fields or on a button
if (
isContentEditableDiv(event.target as HTMLElement) ||
(event.which === 1 && isChildOfNodeName(event.target as Element, 'BUTTON')) // left mouse on a button
(event.buttons === 1 && isChildOfNodeName(event.target as Element, 'BUTTON')) // left mouse on a button
) {
return
}
Expand Down

0 comments on commit d0e7f4c

Please sign in to comment.