From 5318fc3ff38229f9a6fabcf0dbe02ea8620e7d2e Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Wed, 18 Feb 2026 18:02:13 -0700 Subject: [PATCH] MM-66830: Fix RHS panel snapping to minimum width on resize (#35236) Race condition caused mousemove events to fire after reset() but before cleanup, resulting in negative width calculations that CSS clamped to min-width. --- .../resizable_sidebar/resizable_divider.tsx | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/webapp/channels/src/components/resizable_sidebar/resizable_divider.tsx b/webapp/channels/src/components/resizable_sidebar/resizable_divider.tsx index 349dc7c4033..b622c7cf9d0 100644 --- a/webapp/channels/src/components/resizable_sidebar/resizable_divider.tsx +++ b/webapp/channels/src/components/resizable_sidebar/resizable_divider.tsx @@ -129,7 +129,10 @@ function ResizableDivider({ return; } previousClientX.current = e.clientX; - startWidth.current = containerRef.current.getBoundingClientRect().width; + + const currentWidth = containerRef.current.getBoundingClientRect().width; + startWidth.current = currentWidth; + lastWidth.current = currentWidth; setIsActive(true); @@ -160,7 +163,24 @@ function ResizableDivider({ e.preventDefault(); - const previousWidth = lastWidth.current ?? 0; + // Prevent race condition - if lastWidth is null, recover from container + // This can occur when a mousemove event fires after reset() but before cleanup + let previousWidth = lastWidth.current; + if (previousWidth === null || previousWidth === 0) { + const currentWidth = containerRef.current?.getBoundingClientRect().width ?? 0; + if (currentWidth > 0) { + previousWidth = currentWidth; + lastWidth.current = currentWidth; + previousClientX.current = e.clientX; + + // Skip this mousemove, start fresh on next one + return; + } + + // If we can't determine width, return early to prevent negative width + return; + } + let widthDiff = 0; switch (dir) {