Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sometimes the panel dragger is not stable #667

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading