Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

feat(planner): planner panels widen as far as the window allows and follow the drag without lag

Mauricea1bf57b71a4b
diff --git a/client/src/hooks/useResizablePanels.ts b/client/src/hooks/useResizablePanels.ts
index 8b3a81beb..9e5484a40 100644
--- a/client/src/hooks/useResizablePanels.ts
+++ b/client/src/hooks/useResizablePanels.ts
@@ -1,7 +1,6 @@
import { useState, useEffect, useRef, useCallback } from 'react'
const MIN_SIDEBAR = 200
-const MAX_SIDEBAR = 520
/**
* The band where the desktop planner renders but two panels leave the map a
* useless strip. Below 768 the phone shell takes over, so the squeeze lives
@@ -9,13 +8,21 @@ const MAX_SIDEBAR = 520
* ~860 CSS px, where 340 + 300 of panel left the map 200 px (#2247).
*/
const NARROW_QUERY = '(min-width: 768px) and (max-width: 1023px)'
-/** However wide a panel was dragged on a big screen, the map keeps this much. */
+/** However wide the panels are dragged, the map between them keeps this much... */
const MIN_MAP = 360
+/** ...and on a big screen at least this share of the window, so it stays a map and not a strip. */
+const MIN_MAP_SHARE = 0.35
+/** Each panel floats 10 px off its side of the screen. */
+const SCREEN_MARGINS = 20
-function clampWidth(w: number, max: number = MAX_SIDEBAR): number {
+function clampWidth(w: number, max: number): number {
return Math.max(MIN_SIDEBAR, Math.min(max, w))
}
+function readWidth(key: string, fallback: number): number {
+ try { return Number.parseInt(localStorage.getItem(key) || '') || fallback } catch { return fallback }
+}
+
/** Stores a dragged width and hands it back; a blocked storage only costs the memory of it. */
function remember(key: string, w: number): number {
try { localStorage.setItem(key, String(w)) } catch { /* not remembered, still applied */ }
@@ -23,12 +30,16 @@ function remember(key: string, w: number): number {
}
export function useResizablePanels() {
- const [leftWidth, setLeftWidth] = useState<number>(() => Number.parseInt(localStorage.getItem('sidebarLeftWidth') || '') || 340)
- const [rightWidth, setRightWidth] = useState<number>(() => Number.parseInt(localStorage.getItem('sidebarRightWidth') || '') || 300)
+ const [leftWidth, setLeftWidth] = useState<number>(() => readWidth('sidebarLeftWidth', 340))
+ const [rightWidth, setRightWidth] = useState<number>(() => readWidth('sidebarRightWidth', 300))
const [leftCollapsed, setLeftCollapsed] = useState(false)
const [rightCollapsed, setRightCollapsed] = useState(false)
const isResizingLeft = useRef(false)
const isResizingRight = useRef(false)
+ // While a handle is held the panel follows the pointer 1:1. Its width transition
+ // stays for collapsing and opening, but during a drag it made the panel trail
+ // behind the map and its buttons, which move at once.
+ const [resizing, setResizing] = useState(false)
const [narrow, setNarrow] = useState(
() => typeof window !== 'undefined' && window.matchMedia(NARROW_QUERY).matches,
@@ -38,7 +49,7 @@ export function useResizablePanels() {
// null is map-only. Deliberately separate from the two collapse flags, which stay
// the wide-layout state — folding back to a wide window restores what was there.
const [narrowPanel, setNarrowPanel] = useState<'left' | 'right' | null>('left')
- const [maxPanel, setMaxPanel] = useState(Number.POSITIVE_INFINITY)
+ const [viewportWidth, setViewportWidth] = useState(() => (typeof window !== 'undefined' ? window.innerWidth : 1280))
useEffect(() => {
const mq = window.matchMedia(NARROW_QUERY)
@@ -48,22 +59,38 @@ export function useResizablePanels() {
return () => mq.removeEventListener('change', handler)
}, [])
- // Only measured inside the narrow band: that is the only place the clamp can
- // bite, and a resize listener on every planner mount is not worth the rest.
+ // The panels have no fixed ceiling: they may take whatever the window leaves
+ // after the map's share, so a wide screen gets a wide day plan.
useEffect(() => {
- if (!narrow) { setMaxPanel(Number.POSITIVE_INFINITY); return }
- const measure = () => setMaxPanel(Math.max(MIN_SIDEBAR, window.innerWidth - MIN_MAP - 20))
+ const measure = () => setViewportWidth(window.innerWidth)
measure()
window.addEventListener('resize', measure)
return () => window.removeEventListener('resize', measure)
- }, [narrow])
+ }, [])
+
+ // What the layout actually shows. The collapse flags stay the caller's intent —
+ // handlePlaceClick reopening "both" must not re-crowd a narrow screen.
+ const leftHidden = narrow ? narrowPanel !== 'left' : leftCollapsed
+ const rightHidden = narrow ? narrowPanel !== 'right' : rightCollapsed
+
+ // Room both panels share. The day plan comes first: it keeps its width and the
+ // places list gets what is left, so a window that shrinks squeezes the right side.
+ const minMap = Math.max(MIN_MAP, Math.round(viewportWidth * MIN_MAP_SHARE))
+ const room = Math.max(MIN_SIDEBAR, viewportWidth - minMap - SCREEN_MARGINS)
+ const shownLeft = clampWidth(leftWidth, Math.max(MIN_SIDEBAR, room - (rightHidden ? 0 : MIN_SIDEBAR)))
+ const resizeMaxRight = Math.max(MIN_SIDEBAR, room - (leftHidden ? 0 : shownLeft))
+ const shownRight = clampWidth(rightWidth, resizeMaxRight)
+ const resizeMaxLeft = Math.max(MIN_SIDEBAR, room - (rightHidden ? 0 : shownRight))
+ // The drag listeners are bound once, so they read the live ceilings from here.
+ const maxRef = useRef({ left: resizeMaxLeft, right: resizeMaxRight })
+ useEffect(() => { maxRef.current = { left: resizeMaxLeft, right: resizeMaxRight } }, [resizeMaxLeft, resizeMaxRight])
// A mouse drags through mousemove; a finger on a tablet sends touch events and
// never a mousemove, which is why the handles used to be dead on an iPad (#1012).
useEffect(() => {
const moveTo = (clientX: number) => {
- if (isResizingLeft.current) setLeftWidth(remember('sidebarLeftWidth', clampWidth(clientX - 10)))
- if (isResizingRight.current) setRightWidth(remember('sidebarRightWidth', clampWidth(window.innerWidth - clientX - 10)))
+ if (isResizingLeft.current) setLeftWidth(remember('sidebarLeftWidth', clampWidth(clientX - 10, maxRef.current.left)))
+ if (isResizingRight.current) setRightWidth(remember('sidebarRightWidth', clampWidth(window.innerWidth - clientX - 10, maxRef.current.right)))
}
const onMove = (e: MouseEvent) => moveTo(e.clientX)
const onTouchMove = (e: TouchEvent) => {
@@ -75,8 +102,10 @@ export function useResizablePanels() {
moveTo(touch.clientX)
}
const onUp = () => {
+ if (!isResizingLeft.current && !isResizingRight.current) return
isResizingLeft.current = false
isResizingRight.current = false
+ setResizing(false)
document.body.style.cursor = ''
document.body.style.userSelect = ''
}
@@ -94,19 +123,14 @@ export function useResizablePanels() {
}
}, [])
- const startResizeLeft = () => { isResizingLeft.current = true; document.body.style.cursor = 'col-resize'; document.body.style.userSelect = 'none' }
- const startResizeRight = () => { isResizingRight.current = true; document.body.style.cursor = 'col-resize'; document.body.style.userSelect = 'none' }
+ const beginResize = () => { setResizing(true); document.body.style.cursor = 'col-resize'; document.body.style.userSelect = 'none' }
+ const startResizeLeft = () => { isResizingLeft.current = true; beginResize() }
+ const startResizeRight = () => { isResizingRight.current = true; beginResize() }
// The handles are separators a keyboard can move too: an arrow key grows or
// shrinks the panel by a step, from the width it shows right now.
- const resizeMax = Math.max(MIN_SIDEBAR, Math.min(MAX_SIDEBAR, maxPanel))
- const nudgeLeft = (delta: number) => setLeftWidth(remember('sidebarLeftWidth', clampWidth(Math.min(leftWidth, maxPanel) + delta, resizeMax)))
- const nudgeRight = (delta: number) => setRightWidth(remember('sidebarRightWidth', clampWidth(Math.min(rightWidth, maxPanel) + delta, resizeMax)))
-
- // What the layout actually shows. The collapse flags stay the caller's intent —
- // handlePlaceClick reopening "both" must not re-crowd a narrow screen.
- const leftHidden = narrow ? narrowPanel !== 'left' : leftCollapsed
- const rightHidden = narrow ? narrowPanel !== 'right' : rightCollapsed
+ const nudgeLeft = (delta: number) => setLeftWidth(remember('sidebarLeftWidth', clampWidth(shownLeft + delta, resizeMaxLeft)))
+ const nudgeRight = (delta: number) => setRightWidth(remember('sidebarRightWidth', clampWidth(shownRight + delta, resizeMaxRight)))
const toggleLeft = useCallback(() => {
if (narrow) setNarrowPanel(p => (p === 'left' ? null : 'left'))
@@ -118,13 +142,13 @@ export function useResizablePanels() {
}, [narrow])
return {
- // Clamped for the layout; the stored width is left alone, so a 520 px panel
- // dragged on a desktop comes back untouched once there is room for it again.
- leftWidth: Math.min(leftWidth, maxPanel),
- rightWidth: Math.min(rightWidth, maxPanel),
+ // Clamped for the layout; the stored width is left alone, so a wide panel
+ // dragged on a big screen comes back untouched once there is room for it again.
+ leftWidth: shownLeft,
+ rightWidth: shownRight,
leftCollapsed, rightCollapsed, setLeftCollapsed, setRightCollapsed,
leftHidden, rightHidden, toggleLeft, toggleRight, narrow,
- startResizeLeft, startResizeRight, nudgeLeft, nudgeRight,
- resizeMin: MIN_SIDEBAR, resizeMax,
+ startResizeLeft, startResizeRight, nudgeLeft, nudgeRight, resizing,
+ resizeMin: MIN_SIDEBAR, resizeMaxLeft, resizeMaxRight,
}
}
diff --git a/client/src/pages/TripPlannerPage.tsx b/client/src/pages/TripPlannerPage.tsx
index 7b845cdf7..ffb838de3 100644
--- a/client/src/pages/TripPlannerPage.tsx
+++ b/client/src/pages/TripPlannerPage.tsx
@@ -76,7 +76,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
TRANSPORT_TYPES, TRIP_TABS, activeTab, setActiveTab, handleTabChange,
leftWidth, rightWidth,
leftHidden, rightHidden, toggleLeft, toggleRight,
- startResizeLeft, startResizeRight, nudgeLeft, nudgeRight, resizeMin, resizeMax,
+ startResizeLeft, startResizeRight, nudgeLeft, nudgeRight, resizing, resizeMin, resizeMaxLeft, resizeMaxRight,
selectedPlaceId, selectedAssignmentId, setSelectedPlaceId, selectAssignment,
showDayDetail, setShowDayDetail, dayDetailCollapsed, setDayDetailCollapsed,
stayPickerDayId, setStayPickerDayId,
@@ -294,7 +294,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
boxShadow: leftHidden ? 'none' : 'var(--sidebar-shadow)',
borderRadius: 16,
overflow: 'hidden', display: 'flex', flexDirection: 'column',
- transition: 'width 0.25s ease',
+ transition: resizing ? 'none' : 'width 0.25s ease',
opacity: leftHidden ? 0 : 1,
}}>
{enabledAddons.roadtrip && (
@@ -402,7 +402,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
/>
)}
{!leftHidden && (
- <PanelResizeHandle side="left" width={leftWidth} min={resizeMin} max={resizeMax} onStart={startResizeLeft} onNudge={nudgeLeft} />
+ <PanelResizeHandle side="left" width={leftWidth} min={resizeMin} max={resizeMaxLeft} onStart={startResizeLeft} onNudge={nudgeLeft} />
)}
</div>
</div>
@@ -418,11 +418,11 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
boxShadow: rightHidden ? 'none' : 'var(--sidebar-shadow)',
borderRadius: 16,
overflow: 'hidden', display: 'flex', flexDirection: 'column',
- transition: 'width 0.25s ease',
+ transition: resizing ? 'none' : 'width 0.25s ease',
opacity: rightHidden ? 0 : 1,
}}>
{!rightHidden && (
- <PanelResizeHandle side="right" width={rightWidth} min={resizeMin} max={resizeMax} onStart={startResizeRight} onNudge={nudgeRight} />
+ <PanelResizeHandle side="right" width={rightWidth} min={resizeMin} max={resizeMaxRight} onStart={startResizeRight} onNudge={nudgeRight} />
)}
<div style={{ flex: 1, overflow: 'hidden', display: 'flex', flexDirection: 'column' }}>
{roadtripActive ? (
@@ -633,9 +633,9 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
background: 'var(--sidebar-bg)', backdropFilter: 'blur(24px) saturate(180%)',
WebkitBackdropFilter: 'blur(24px) saturate(180%)', boxShadow: leftHidden ? 'none' : 'var(--sidebar-shadow)',
borderRadius: 16, overflow: 'hidden', display: 'flex', flexDirection: 'column',
- transition: 'width 0.25s ease', opacity: leftHidden ? 0 : 1,
+ transition: resizing ? 'none' : 'width 0.25s ease', opacity: leftHidden ? 0 : 1,
}}>
- {!leftHidden && <PanelResizeHandle side="left" width={leftWidth} min={resizeMin} max={resizeMax} onStart={startResizeLeft} onNudge={nudgeLeft} />}
+ {!leftHidden && <PanelResizeHandle side="left" width={leftWidth} min={resizeMin} max={resizeMaxLeft} onStart={startResizeLeft} onNudge={nudgeLeft} />}
<LazyPanel id="tour-planner-rail"><TourWorkspaceRail workspace={pageState} canEdit={canPlaceEdit} canAssign={canDayEdit} /></LazyPanel>
</div>
</div>
@@ -654,7 +654,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
style={{
width: rightHidden ? 0 : rightWidth,
opacity: rightHidden ? 0 : 1,
- transition: 'width 0.25s ease, opacity 0.25s ease',
+ transition: resizing ? 'opacity 0.25s ease' : 'width 0.25s ease, opacity 0.25s ease',
background: 'var(--sidebar-bg)',
backdropFilter: 'blur(24px) saturate(180%)',
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
@@ -662,7 +662,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
}}
>
{!rightHidden && (
- <PanelResizeHandle side="right" width={rightWidth} min={resizeMin} max={resizeMax} onStart={startResizeRight} onNudge={nudgeRight} />
+ <PanelResizeHandle side="right" width={rightWidth} min={resizeMin} max={resizeMaxRight} onStart={startResizeRight} onNudge={nudgeRight} />
)}
{!rightHidden && (
<LazyPanel id="tour-planner-tours">
diff --git a/client/src/pages/TripPlannerPage.wiring.fixture.ts b/client/src/pages/TripPlannerPage.wiring.fixture.ts
index 1f0f831a0..798e66049 100644
--- a/client/src/pages/TripPlannerPage.wiring.fixture.ts
+++ b/client/src/pages/TripPlannerPage.wiring.fixture.ts
@@ -174,8 +174,10 @@ function layoutState(): HookState {
startResizeRight: vi.fn(),
nudgeLeft: vi.fn(),
nudgeRight: vi.fn(),
+ resizing: false,
resizeMin: 200,
- resizeMax: 520,
+ resizeMaxLeft: 520,
+ resizeMaxRight: 520,
selectedPlaceId: null,
selectedAssignmentId: null,
setSelectedPlaceId: vi.fn(),
diff --git a/client/src/pages/TripPlannerPage.wiring.test.tsx b/client/src/pages/TripPlannerPage.wiring.test.tsx
index 823e7d866..a5e9986f3 100644
--- a/client/src/pages/TripPlannerPage.wiring.test.tsx
+++ b/client/src/pages/TripPlannerPage.wiring.test.tsx
@@ -260,7 +260,7 @@ describe('TripPlannerPage — shell', () => {
{ leftHidden: true, rightHidden: false, visibleSide: 'right', leftInset: 0, rightInset: 300 },
])('UI-R2: the 768-1023px panel state shows only its selected rail ($visibleSide)', ({ leftHidden, rightHidden, visibleSide, leftInset, rightInset }) => {
const { container } = renderToursPage({ narrowPanels: true,
- leftHidden, rightHidden, leftWidth: 300, rightWidth: 300, resizeMax: 300 })
+ leftHidden, rightHidden, leftWidth: 300, rightWidth: 300, resizeMaxLeft: 300, resizeMaxRight: 300 })
const handles = container.querySelectorAll<HTMLElement>('div[role="separator"]')
expect(handles).toHaveLength(1)
expect(handles[0]).toHaveAttribute('data-resize', visibleSide)
diff --git a/client/src/pages/tripPlanner/useTripPlanner.ts b/client/src/pages/tripPlanner/useTripPlanner.ts
index d9828b12b..8c913dd32 100644
--- a/client/src/pages/tripPlanner/useTripPlanner.ts
+++ b/client/src/pages/tripPlanner/useTripPlanner.ts
@@ -310,7 +310,7 @@ export function useTripPlanner() {
const {
leftWidth, rightWidth, leftCollapsed, rightCollapsed, setLeftCollapsed, setRightCollapsed,
leftHidden, rightHidden, toggleLeft, toggleRight, narrow: narrowPanels,
- startResizeLeft, startResizeRight, nudgeLeft, nudgeRight, resizeMin, resizeMax,
+ startResizeLeft, startResizeRight, nudgeLeft, nudgeRight, resizing, resizeMin, resizeMaxLeft, resizeMaxRight,
} = useResizablePanels()
const { selectedPlaceId, selectedAssignmentId, setSelectedPlaceId, selectAssignment } = usePlaceSelection()
const toursEnabled = useAddonStore(state => state.isEnabled('tours'))
@@ -747,7 +747,7 @@ export function useTripPlanner() {
TRANSPORT_TYPES, TRIP_TABS, activeTab, setActiveTab, handleTabChange, tabLink,
leftWidth, rightWidth, leftCollapsed, rightCollapsed, setLeftCollapsed, setRightCollapsed,
leftHidden, rightHidden, toggleLeft, toggleRight, narrowPanels,
- startResizeLeft, startResizeRight, nudgeLeft, nudgeRight, resizeMin, resizeMax,
+ startResizeLeft, startResizeRight, nudgeLeft, nudgeRight, resizing, resizeMin, resizeMaxLeft, resizeMaxRight,
selectedPlaceId, selectedAssignmentId, setSelectedPlaceId, selectAssignment,
toursEnabled, toursMode, setToursMode, tours, toursLoading, tourDataReady, tourPlaceIds,
reloadTourPlaceIds, invalidateTourPlaceIds, upsertTour, selectedTour, tourStageStops,
diff --git a/client/tests/integration/hooks/useResizablePanels.test.ts b/client/tests/integration/hooks/useResizablePanels.test.ts
index 989afbfa4..c0b7102ca 100644
--- a/client/tests/integration/hooks/useResizablePanels.test.ts
+++ b/client/tests/integration/hooks/useResizablePanels.test.ts
@@ -78,7 +78,7 @@ describe('useResizablePanels', () => {
result.current.startResizeLeft();
});
- // mousemove with clientX=350 → w = max(200, min(520, 350-10)) = 340
+ // mousemove with clientX=350 → w = 350 - 10 = 340, well inside the room the window leaves
act(() => {
fireEvent.mouseMove(document, { clientX: 350 });
});
@@ -103,7 +103,7 @@ describe('useResizablePanels', () => {
result.current.startResizeRight();
});
- // mousemove with clientX=800 → w = max(200, min(520, 1200-800-10)) = max(200, min(520, 390)) = 390
+ // mousemove with clientX=800 → w = 1200 - 800 - 10 = 390
act(() => {
fireEvent.mouseMove(document, { clientX: 800 });
});
@@ -125,7 +125,7 @@ describe('useResizablePanels', () => {
result.current.startResizeLeft();
});
- // clientX=50 → w = max(200, min(520, 50-10)) = max(200, 40) = 200
+ // clientX=50 → w = 40, held at the 200 minimum
act(() => {
fireEvent.mouseMove(document, { clientX: 50 });
});
@@ -133,19 +133,78 @@ describe('useResizablePanels', () => {
expect(result.current.leftWidth).toBe(200);
});
- it('FE-HOOK-PANELS-010: max width constraint (520) is enforced for left panel', () => {
+ it('FE-HOOK-PANELS-010: the left panel stops where the map would drop below 35% of the window next to the places list', () => {
+ setViewport(1200, false);
const { result } = renderHook(() => useResizablePanels());
act(() => {
result.current.startResizeLeft();
});
- // clientX=600 → w = max(200, min(520, 600-10)) = min(520, 590) = 520
+ // 1200 - 420 map (35%) - 20 margins - 300 places list = 460
act(() => {
- fireEvent.mouseMove(document, { clientX: 600 });
+ fireEvent.mouseMove(document, { clientX: 1100 });
});
- expect(result.current.leftWidth).toBe(520);
+ expect(result.current.leftWidth).toBe(460);
+ expect(result.current.resizeMaxLeft).toBe(460);
+ });
+
+ it('FE-HOOK-PANELS-010b: a wide screen lets the day plan grow well past the old 520px ceiling', () => {
+ setViewport(1920, false);
+ const { result } = renderHook(() => useResizablePanels());
+
+ act(() => {
+ result.current.startResizeLeft();
+ });
+ act(() => {
+ fireEvent.mouseMove(document, { clientX: 910 });
+ });
+
+ expect(result.current.leftWidth).toBe(900);
+ expect(localStorage.getItem('sidebarLeftWidth')).toBe('900');
+ });
+
+ it('FE-HOOK-PANELS-010c: with the places list collapsed the day plan may take its room too', () => {
+ setViewport(1920, false);
+ const { result } = renderHook(() => useResizablePanels());
+
+ act(() => { result.current.toggleRight(); });
+ act(() => {
+ result.current.nudgeLeft(10_000);
+ });
+
+ // 1920 - 672 map (35%) - 20 margins
+ expect(result.current.leftWidth).toBe(1228);
+ });
+
+ it('FE-HOOK-PANELS-010d: a window too small for both stored widths squeezes the places list, not the day plan', () => {
+ localStorage.setItem('sidebarLeftWidth', '700');
+ localStorage.setItem('sidebarRightWidth', '600');
+ setViewport(1600, false);
+ const { result } = renderHook(() => useResizablePanels());
+
+ // room 1600 - 560 map (35%) - 20 = 1020: the day plan keeps 700, the list gets 320
+ expect(result.current.leftWidth).toBe(700);
+ expect(result.current.rightWidth).toBe(320);
+ expect(localStorage.getItem('sidebarRightWidth')).toBe('600');
+ });
+
+ it('FE-HOOK-PANELS-010e: shrinking the window shrinks the ceiling with it', () => {
+ localStorage.setItem('sidebarLeftWidth', '900');
+ setViewport(1920, false);
+ const { result } = renderHook(() => useResizablePanels());
+ expect(result.current.leftWidth).toBe(900);
+
+ act(() => {
+ Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 1200 });
+ window.dispatchEvent(new Event('resize'));
+ });
+
+ // room 1200 - 420 map (35%) - 20 = 760: the places list is held at its 200 minimum, the day plan gets 560
+ expect(result.current.leftWidth).toBe(560);
+ expect(result.current.rightWidth).toBe(200);
+ expect(localStorage.getItem('sidebarLeftWidth')).toBe('900');
});
it('FE-HOOK-PANELS-011: mousemove without prior startResize does nothing', () => {
@@ -201,7 +260,7 @@ describe('useResizablePanels', () => {
act(() => {
result.current.nudgeRight(10_000);
});
- expect(result.current.rightWidth).toBe(result.current.resizeMax);
+ expect(result.current.rightWidth).toBe(result.current.resizeMaxRight);
});
it('FE-HOOK-PANELS-012: body userSelect set to none during resize, cleared on mouseup', () => {
@@ -220,6 +279,21 @@ describe('useResizablePanels', () => {
expect(document.body.style.userSelect).toBe('');
});
+ it('FE-HOOK-PANELS-012b: a drag reports itself, so the panel can drop its width animation while it follows the pointer', () => {
+ const { result } = renderHook(() => useResizablePanels());
+ expect(result.current.resizing).toBe(false);
+
+ act(() => {
+ result.current.startResizeRight();
+ });
+ expect(result.current.resizing).toBe(true);
+
+ act(() => {
+ fireEvent.mouseUp(document);
+ });
+ expect(result.current.resizing).toBe(false);
+ });
+
it('FE-HOOK-PANELS-013: leftCollapsed and rightCollapsed default to false', () => {
const { result } = renderHook(() => useResizablePanels());
expect(result.current.leftCollapsed).toBe(false);
@@ -308,7 +382,7 @@ describe('useResizablePanels', () => {
it('FE-HOOK-PANELS-022: a wide layout leaves the stored widths alone', () => {
localStorage.setItem('sidebarLeftWidth', '520');
- setViewport(1100, false);
+ setViewport(1440, false);
const { result } = renderHook(() => useResizablePanels());
expect(result.current.leftWidth).toBe(520);
});