Skip to content

Commit 81a9e74

Browse files
authored
Fix onMouseDown causing width to snap back to persisted width (#268)
* Fix onMouseDown causing width to snap back to persisted width * var name change * remove logs * remove redundant call
1 parent 679e85a commit 81a9e74

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/app/common/common.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,8 +1287,8 @@ class ResizableSidebar extends React.Component<ResizableSidebarProps> {
12871287
startResizing(event: React.MouseEvent<HTMLDivElement>) {
12881288
event.preventDefault();
12891289

1290-
let { parentRef, position } = this.props;
1291-
let parentRect = parentRef.current?.getBoundingClientRect();
1290+
const { parentRef, position } = this.props;
1291+
const parentRect = parentRef.current?.getBoundingClientRect();
12921292

12931293
if (!parentRect) return;
12941294

@@ -1298,15 +1298,17 @@ class ResizableSidebar extends React.Component<ResizableSidebarProps> {
12981298
this.startX = event.clientX - parentRect.left;
12991299
}
13001300

1301-
this.resizeStartWidth = GlobalModel.mainSidebarModel.getWidth();
1301+
const mainSidebarModel = GlobalModel.mainSidebarModel;
1302+
const collapsed = mainSidebarModel.getCollapsed();
1303+
1304+
this.resizeStartWidth = collapsed ? MagicLayout.MainSidebarMinWidth : mainSidebarModel.getWidth();
13021305
document.addEventListener("mousemove", this.onMouseMove);
13031306
document.addEventListener("mouseup", this.stopResizing);
13041307

13051308
document.body.style.cursor = "col-resize";
13061309
mobx.action(() => {
1307-
const sbm = GlobalModel.mainSidebarModel;
1308-
sbm.setTempWidthAndTempCollapsed(this.resizeStartWidth, sbm.getCollapsed());
1309-
sbm.isDragging.set(true);
1310+
mainSidebarModel.setTempWidthAndTempCollapsed(this.resizeStartWidth, collapsed);
1311+
mainSidebarModel.isDragging.set(true);
13101312
})();
13111313
}
13121314

0 commit comments

Comments
 (0)