diff --git a/src/app/common/common.tsx b/src/app/common/common.tsx index 787ace34..b2f08881 100644 --- a/src/app/common/common.tsx +++ b/src/app/common/common.tsx @@ -1287,8 +1287,8 @@ class ResizableSidebar extends React.Component { startResizing(event: React.MouseEvent) { event.preventDefault(); - let { parentRef, position } = this.props; - let parentRect = parentRef.current?.getBoundingClientRect(); + const { parentRef, position } = this.props; + const parentRect = parentRef.current?.getBoundingClientRect(); if (!parentRect) return; @@ -1298,15 +1298,17 @@ class ResizableSidebar extends React.Component { this.startX = event.clientX - parentRect.left; } - this.resizeStartWidth = GlobalModel.mainSidebarModel.getWidth(); + const mainSidebarModel = GlobalModel.mainSidebarModel; + const collapsed = mainSidebarModel.getCollapsed(); + + this.resizeStartWidth = collapsed ? MagicLayout.MainSidebarMinWidth : mainSidebarModel.getWidth(); document.addEventListener("mousemove", this.onMouseMove); document.addEventListener("mouseup", this.stopResizing); document.body.style.cursor = "col-resize"; mobx.action(() => { - const sbm = GlobalModel.mainSidebarModel; - sbm.setTempWidthAndTempCollapsed(this.resizeStartWidth, sbm.getCollapsed()); - sbm.isDragging.set(true); + mainSidebarModel.setTempWidthAndTempCollapsed(this.resizeStartWidth, collapsed); + mainSidebarModel.isDragging.set(true); })(); }