Skip to content

Commit d720801

Browse files
committed
Merge branch 'fix/terminal-height-survives-window' into fix/sidebar-width-scoped-vars
2 parents 8dbb614 + 60ef839 commit d720801

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎apps/web/src/hooks/useResizableWidth.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export function useResizableWidth(options: UseResizableWidthOptions): {
8383

8484
const clampedWidth = clamp(widthState.width);
8585
const latestOptions = useRef({ clamp, storageKey, width: clampedWidth });
86+
useLayoutEffect(() => {
87+
latestOptions.current = { clamp, storageKey, width: clampedWidth };
88+
}, [clamp, clampedWidth, storageKey]);
8689

8790
const { refresh, ...handlers } = useResizeDrag<HTMLElement>((event) => {
8891
const host = event.currentTarget.parentElement;
@@ -116,12 +119,9 @@ export function useResizableWidth(options: UseResizableWidthOptions): {
116119
};
117120
}, storageKey);
118121

119-
useLayoutEffect(() => {
120-
latestOptions.current = { clamp, storageKey, width: clampedWidth };
121-
// Bounds can change mid-drag (sidebar opens, window narrows) and the render
122-
// rewrites the committed width, so re-apply the live pointer position.
123-
refresh();
124-
}, [clamp, clampedWidth, storageKey]);
122+
// Bounds can change mid-drag (sidebar opens, window narrows) and the render
123+
// rewrites the committed width, so re-apply the live pointer position.
124+
useLayoutEffect(refresh, [clamp, clampedWidth, refresh]);
125125

126126
return { width: clampedWidth, handlers };
127127
}

0 commit comments

Comments
 (0)