Skip to content

Commit

Permalink
fix sometimes the panel dragger is not stable (#667)
Browse files Browse the repository at this point in the history
* fix sometimes the panel dragger is not stable

Signed-off-by: ryjiang <[email protected]>

* remove console

Signed-off-by: ryjiang <[email protected]>

---------

Signed-off-by: ryjiang <[email protected]>
  • Loading branch information
shanghaikid authored Oct 18, 2024
1 parent e2e4baa commit be0608e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions client/src/pages/databases/Databases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ const useStyles = makeStyles((theme: Theme) => ({
cursor: 'ew-resize',
background: theme.palette.divider,
},
'&.tree-collapsed': {
background: theme.palette.divider,
},
},
tab: {
flexGrow: 1,
Expand Down Expand Up @@ -114,18 +111,15 @@ const Databases = () => {

// set tree width
setUIPref({ tree: { width: treeWidth } });
// set dragging true
setIsDragging(true);
});
};

const handleMouseUp = () => {
document.removeEventListener('mousemove', handleMouseMove);
document.removeEventListener('mouseup', handleMouseUp);
// set dragging false
setIsDragging(false);
// highlight dragger alwasy if width === 1
draggerRef.current!.classList.toggle('tree-collapsed', treeWidth === 1);
// set dragging true
setIsDragging(false);
document.removeEventListener('mousemove', handleMouseMove);
};

const handleMouseDown = (e: MouseEvent) => {
Expand All @@ -135,6 +129,7 @@ const Databases = () => {
setIsDragging(true);
document.addEventListener('mousemove', handleMouseMove);
document.addEventListener('mouseup', handleMouseUp);
e.stopPropagation();
}
};

Expand All @@ -146,7 +141,7 @@ const Databases = () => {
// set dragging false
setIsDragging(false);
};
}, []);
}, [isDragging]);

// double click on the dragger, recover default
const handleDoubleClick = () => {
Expand Down

0 comments on commit be0608e

Please sign in to comment.