From 81a9e7499180ebb3b3cdea3f36d0c8791f5c8e1e Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Tue, 30 Jan 2024 22:23:00 -0800 Subject: [PATCH] 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 --- src/app/common/common.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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); })(); }