From 3e6692b09ed59e9ce63e5a125fb6a02726e6ef0a Mon Sep 17 00:00:00 2001 From: Michael Daines <1383+mdaines@users.noreply.github.com> Date: Wed, 13 Nov 2024 09:05:09 -0500 Subject: [PATCH] Set editor width to actual width at end of resize --- packages/website/src/components/Resize.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/website/src/components/Resize.jsx b/packages/website/src/components/Resize.jsx index 8a02a72..6e22260 100644 --- a/packages/website/src/components/Resize.jsx +++ b/packages/website/src/components/Resize.jsx @@ -7,20 +7,25 @@ export default function Resize({ onResize }) { function handleMouseDown(e) { e.preventDefault(); - const rect = e.target.getBoundingClientRect(); + const resizeRect = resizeRef.current.getBoundingClientRect(); dragging = true; - dragOffset = Math.round(e.clientX - rect.left); + dragOffset = Math.round(e.clientX - resizeRect.left); } function handleMouseMove(e) { if (dragging) { - let width = Math.max(0, e.clientX - dragOffset); + const width = Math.max(0, e.clientX - dragOffset); onResize(width); } } function handleMouseUp() { + if (dragging) { + const resizeRect = resizeRef.current.getBoundingClientRect(); + onResize(resizeRect.left); + } + dragging = false; }