Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(electron): align TabBar left padding with NavPanel width on initial load (#13981)

Innei3bd7f1f1468b
diff --git a/src/features/Electron/titlebar/NavigationBar.tsx b/src/features/Electron/titlebar/NavigationBar.tsx
index 5f80ef2c6ff..74b416a6146 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 f2f44ed051f..f86dcabbaa0 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<NavPanelDraggableProps>(({ 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<NavPanelDraggableProps>(({ activeContent }
[],
);
+ if (defaultWidthRef.current === 0) {
+ const pendingWidth = systemStatusSelectors.leftPanelWidth(useGlobalStore.getState());
+ return <div aria-hidden style={{ flexShrink: 0, height: '100%', width: pendingWidth }} />;
+ }
+
+ const defaultSize = { height: '100%', width: defaultWidthRef.current };
+
return (
<DraggablePanel
className={draggableStyles.panel}