diff --git a/src/features/Electron/titlebar/NavigationBar.tsx b/src/features/Electron/titlebar/NavigationBar.tsx index 5f80ef2c6f..74b416a614 100644 --- a/src/features/Electron/titlebar/NavigationBar.tsx +++ b/src/features/Electron/titlebar/NavigationBar.tsx @@ -87,6 +87,7 @@ const NavigationBar = memo(() => { data-width={leftPanelWidth} justify="end" style={{ + paddingRight: 8, width: isLeftPanelVisible ? `${leftPanelWidth - 12}px` : '150px', transition: !isLeftPanelVisible ? 'width 0.2s' : 'none', }} diff --git a/src/features/NavPanel/components/NavPanelDraggable.tsx b/src/features/NavPanel/components/NavPanelDraggable.tsx index f2f44ed051..f86dcabbaa 100644 --- a/src/features/NavPanel/components/NavPanelDraggable.tsx +++ b/src/features/NavPanel/components/NavPanelDraggable.tsx @@ -106,24 +106,20 @@ const classNames = { }; export const NavPanelDraggable = memo(({ activeContent }) => { - const [expand, togglePanel] = useGlobalStore((s) => [ + const [expand, togglePanel, isStatusInit] = useGlobalStore((s) => [ systemStatusSelectors.showLeftPanel(s), s.toggleLeftPanel, + systemStatusSelectors.isStatusInit(s), ]); const handleSizeChange = useNavPanelSizeChangeHandler(); + // Defer DraggablePanel mount until system status hydrates; otherwise defaultSize + // captures the pre-hydration default and the DOM drifts off NavigationBar's live width. const defaultWidthRef = useRef(0); - if (defaultWidthRef.current === 0) { + if (defaultWidthRef.current === 0 && isStatusInit) { defaultWidthRef.current = systemStatusSelectors.leftPanelWidth(useGlobalStore.getState()); } - const defaultSize = useMemo( - () => ({ - height: '100%', - width: defaultWidthRef.current, - }), - [], - ); const styles = useMemo( () => ({ background: isDesktop && isMacOS() ? 'transparent' : cssVar.colorBgLayout, @@ -132,6 +128,13 @@ export const NavPanelDraggable = memo(({ activeContent } [], ); + if (defaultWidthRef.current === 0) { + const pendingWidth = systemStatusSelectors.leftPanelWidth(useGlobalStore.getState()); + return
; + } + + const defaultSize = { height: '100%', width: defaultWidthRef.current }; + return (