Spaces:
Sleeping
Fix Results-pane drag bug: content overflowing during fast resize
Browse filesBoth side asides carried `transition-[width] duration-150`, which is
nice for the smooth collapse/expand toggle but interacts badly with
the PaneResizer drag flow:
- Every mousemove fires setRightW (or setLeftW), changing the aside's
width on the next render.
- The CSS transition kicks off a 150ms width animation toward the new
value.
- Inner content (e.g. the EmptyHint card) is laid out at the *new*
width immediately, so it briefly extends past the visually-animating
boundary and bleeds over the canvas's NodePalette blocks.
Two-part fix in App.tsx:
1. Track an `isResizing` flag — flipped true on PaneResizer mousedown,
false on mouseup via a new `onDragChange` callback. The transition
class is only applied when `!isResizing`, so drag updates are
instant and collapse/expand still animates.
2. Add `overflow-x-hidden` to the asides as a defensive clip — anything
that does try to overflow horizontally now gets cut off cleanly
instead of bleeding into the canvas column.
- frontend/src/App.tsx +28 -7
|
@@ -82,6 +82,15 @@ export default function App() {
|
|
| 82 |
const [leftDrawerOpen, setLeftDrawerOpen] = useState(false);
|
| 83 |
const [rightDrawerOpen, setRightDrawerOpen] = useState(false);
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
// Persist user's preferred widths (desktop only; the values are loaded
|
| 86 |
// at mount either way so that toggling screen size restores them).
|
| 87 |
useEffect(() => {
|
|
@@ -166,9 +175,9 @@ export default function App() {
|
|
| 166 |
<div className="flex-1 flex min-h-0">
|
| 167 |
<aside
|
| 168 |
style={{ width: leftWidth }}
|
| 169 |
-
className={`shrink-0 border-r border-edge flex flex-col min-h-0
|
| 170 |
-
|
| 171 |
-
}`}
|
| 172 |
>
|
| 173 |
{leftCollapsed ? (
|
| 174 |
<CollapsedStrip
|
|
@@ -186,6 +195,7 @@ export default function App() {
|
|
| 186 |
setLeftW((w) => Math.min(LEFT_MAX, Math.max(LEFT_MIN, w + dx)))
|
| 187 |
}
|
| 188 |
onDoubleClick={() => setLeftW(LEFT_DEFAULT)}
|
|
|
|
| 189 |
ariaLabel="Resize pipeline input pane"
|
| 190 |
/>
|
| 191 |
)}
|
|
@@ -203,14 +213,15 @@ export default function App() {
|
|
| 203 |
)
|
| 204 |
}
|
| 205 |
onDoubleClick={() => setRightW(RIGHT_DEFAULT)}
|
|
|
|
| 206 |
ariaLabel="Resize results pane"
|
| 207 |
/>
|
| 208 |
)}
|
| 209 |
<aside
|
| 210 |
style={{ width: rightWidth }}
|
| 211 |
-
className={`shrink-0 border-l border-edge flex flex-col min-h-0
|
| 212 |
-
|
| 213 |
-
}`}
|
| 214 |
>
|
| 215 |
{rightCollapsed ? (
|
| 216 |
<CollapsedStrip
|
|
@@ -309,14 +320,22 @@ function CollapsedStrip({
|
|
| 309 |
* relative to the mousedown position. The parent decides whether to add
|
| 310 |
* or subtract dx depending on which edge the handle sits on.
|
| 311 |
* - Double-click snaps the parent's width back to its default.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
*/
|
| 313 |
function PaneResizer({
|
| 314 |
onResize,
|
| 315 |
onDoubleClick,
|
|
|
|
| 316 |
ariaLabel,
|
| 317 |
}: {
|
| 318 |
onResize: (dx: number) => void;
|
| 319 |
onDoubleClick?: () => void;
|
|
|
|
| 320 |
ariaLabel: string;
|
| 321 |
}) {
|
| 322 |
const dragging = useRef(false);
|
|
@@ -336,9 +355,10 @@ function PaneResizer({
|
|
| 336 |
dragging.current = false;
|
| 337 |
document.body.style.cursor = "";
|
| 338 |
document.body.style.userSelect = "";
|
|
|
|
| 339 |
window.removeEventListener("mousemove", onMouseMove);
|
| 340 |
window.removeEventListener("mouseup", onMouseUp);
|
| 341 |
-
}, [onMouseMove]);
|
| 342 |
|
| 343 |
const onMouseDown = (e: React.MouseEvent) => {
|
| 344 |
e.preventDefault();
|
|
@@ -346,6 +366,7 @@ function PaneResizer({
|
|
| 346 |
lastX.current = e.clientX;
|
| 347 |
document.body.style.cursor = "col-resize";
|
| 348 |
document.body.style.userSelect = "none";
|
|
|
|
| 349 |
window.addEventListener("mousemove", onMouseMove);
|
| 350 |
window.addEventListener("mouseup", onMouseUp);
|
| 351 |
};
|
|
|
|
| 82 |
const [leftDrawerOpen, setLeftDrawerOpen] = useState(false);
|
| 83 |
const [rightDrawerOpen, setRightDrawerOpen] = useState(false);
|
| 84 |
|
| 85 |
+
// True while a PaneResizer drag is in flight. We use it to suppress the
|
| 86 |
+
// CSS `transition-[width]` during dragging: setRightW / setLeftW fire on
|
| 87 |
+
// every mousemove, so each value change would otherwise kick off a 150ms
|
| 88 |
+
// animation, causing the visible aside width to lag behind the inner
|
| 89 |
+
// content's layout — the cards would briefly overflow the aside while it
|
| 90 |
+
// animates. With the transition off during drag, width tracks the cursor
|
| 91 |
+
// exactly; we re-enable it for the smooth collapse/expand toggles.
|
| 92 |
+
const [isResizing, setIsResizing] = useState(false);
|
| 93 |
+
|
| 94 |
// Persist user's preferred widths (desktop only; the values are loaded
|
| 95 |
// at mount either way so that toggling screen size restores them).
|
| 96 |
useEffect(() => {
|
|
|
|
| 175 |
<div className="flex-1 flex min-h-0">
|
| 176 |
<aside
|
| 177 |
style={{ width: leftWidth }}
|
| 178 |
+
className={`shrink-0 border-r border-edge flex flex-col min-h-0 ${
|
| 179 |
+
isResizing ? "" : "transition-[width] duration-150"
|
| 180 |
+
} ${leftCollapsed ? "overflow-hidden" : "overflow-x-hidden overflow-y-auto"}`}
|
| 181 |
>
|
| 182 |
{leftCollapsed ? (
|
| 183 |
<CollapsedStrip
|
|
|
|
| 195 |
setLeftW((w) => Math.min(LEFT_MAX, Math.max(LEFT_MIN, w + dx)))
|
| 196 |
}
|
| 197 |
onDoubleClick={() => setLeftW(LEFT_DEFAULT)}
|
| 198 |
+
onDragChange={setIsResizing}
|
| 199 |
ariaLabel="Resize pipeline input pane"
|
| 200 |
/>
|
| 201 |
)}
|
|
|
|
| 213 |
)
|
| 214 |
}
|
| 215 |
onDoubleClick={() => setRightW(RIGHT_DEFAULT)}
|
| 216 |
+
onDragChange={setIsResizing}
|
| 217 |
ariaLabel="Resize results pane"
|
| 218 |
/>
|
| 219 |
)}
|
| 220 |
<aside
|
| 221 |
style={{ width: rightWidth }}
|
| 222 |
+
className={`shrink-0 border-l border-edge flex flex-col min-h-0 overflow-x-hidden ${
|
| 223 |
+
isResizing ? "" : "transition-[width] duration-150"
|
| 224 |
+
} ${rightCollapsed ? "overflow-hidden" : ""}`}
|
| 225 |
>
|
| 226 |
{rightCollapsed ? (
|
| 227 |
<CollapsedStrip
|
|
|
|
| 320 |
* relative to the mousedown position. The parent decides whether to add
|
| 321 |
* or subtract dx depending on which edge the handle sits on.
|
| 322 |
* - Double-click snaps the parent's width back to its default.
|
| 323 |
+
* - onDragChange (optional) fires once with `true` on mousedown and once
|
| 324 |
+
* with `false` on mouseup. App.tsx uses it to suppress the
|
| 325 |
+
* `transition-[width]` on the aside while dragging — every mousemove
|
| 326 |
+
* updates state, and an active CSS transition would lag the visual
|
| 327 |
+
* width behind the cursor while the inner content is already laid out
|
| 328 |
+
* at the new width, briefly overflowing the aside.
|
| 329 |
*/
|
| 330 |
function PaneResizer({
|
| 331 |
onResize,
|
| 332 |
onDoubleClick,
|
| 333 |
+
onDragChange,
|
| 334 |
ariaLabel,
|
| 335 |
}: {
|
| 336 |
onResize: (dx: number) => void;
|
| 337 |
onDoubleClick?: () => void;
|
| 338 |
+
onDragChange?: (resizing: boolean) => void;
|
| 339 |
ariaLabel: string;
|
| 340 |
}) {
|
| 341 |
const dragging = useRef(false);
|
|
|
|
| 355 |
dragging.current = false;
|
| 356 |
document.body.style.cursor = "";
|
| 357 |
document.body.style.userSelect = "";
|
| 358 |
+
onDragChange?.(false);
|
| 359 |
window.removeEventListener("mousemove", onMouseMove);
|
| 360 |
window.removeEventListener("mouseup", onMouseUp);
|
| 361 |
+
}, [onMouseMove, onDragChange]);
|
| 362 |
|
| 363 |
const onMouseDown = (e: React.MouseEvent) => {
|
| 364 |
e.preventDefault();
|
|
|
|
| 366 |
lastX.current = e.clientX;
|
| 367 |
document.body.style.cursor = "col-resize";
|
| 368 |
document.body.style.userSelect = "none";
|
| 369 |
+
onDragChange?.(true);
|
| 370 |
window.addEventListener("mousemove", onMouseMove);
|
| 371 |
window.addEventListener("mouseup", onMouseUp);
|
| 372 |
};
|