From 3aff95c03486c4472fc5b92d139ebc8f0285d0b4 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Mon, 14 Jul 2025 15:09:54 -0600 Subject: [PATCH] splitter hot fix --- .../AppVerticalCodeSplitter.tsx | 9 +++++++-- .../components/ui/layouts/AppSplitter/AppSplitter.tsx | 11 +++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/features/layouts/AppVerticalCodeSplitter/AppVerticalCodeSplitter.tsx b/apps/web/src/components/features/layouts/AppVerticalCodeSplitter/AppVerticalCodeSplitter.tsx index 235b75ff4..1cf1b60bd 100644 --- a/apps/web/src/components/features/layouts/AppVerticalCodeSplitter/AppVerticalCodeSplitter.tsx +++ b/apps/web/src/components/features/layouts/AppVerticalCodeSplitter/AppVerticalCodeSplitter.tsx @@ -47,8 +47,13 @@ export const AppVerticalCodeSplitter = forwardRef { - return !preservedSideValue || preservedSideValue < 80 || refWidth < 120; + (preservedSideValue: number | null, refSize: number) => { + return ( + !preservedSideValue || + preservedSideValue < 80 || + refSize < 120 || + preservedSideValue > refSize - 80 + ); } ); diff --git a/apps/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx b/apps/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx index a7bb38e63..cef6c4321 100644 --- a/apps/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx +++ b/apps/web/src/components/ui/layouts/AppSplitter/AppSplitter.tsx @@ -125,7 +125,7 @@ interface IAppSplitterProps { * Whether to clear saved layout from localStorage on initialization * Can be a boolean or a function that returns a boolean based on preserved side value and container width */ - bustStorageOnInit?: boolean | ((preservedSideValue: number | null, refWidth: number) => boolean); + bustStorageOnInit?: boolean | ((preservedSideValue: number | null, refSize: number) => boolean); /** * Whether to render the left panel content @@ -302,15 +302,18 @@ const AppSplitterBase = forwardRef< // ================================ const bustStorageOnInitSplitter = (preservedSideValue: number | null) => { - const refWidth = containerRef.current?.offsetWidth; + const refSize = + split === 'vertical' + ? containerRef.current?.offsetWidth + : containerRef.current?.offsetHeight; // Don't bust storage if container hasn't been sized yet - if (!refWidth || refWidth === 0) { + if (!refSize || refSize === 0) { // console.warn('AppSplitter: container not sized yet'); return false; } return typeof bustStorageOnInit === 'function' - ? bustStorageOnInit(preservedSideValue, refWidth) + ? bustStorageOnInit(preservedSideValue, refSize) : !!bustStorageOnInit; };