From 000222dba11765ea297e07f5cfa3055c88c4db77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Qu=E1=BB=91c=20=C4=90=E1=BA=A1t?= Date: Wed, 15 Apr 2026 15:04:14 +0700 Subject: [PATCH] fix: sidebar gap when switching between table and query tabs (#759) The "Toggle Results" ToolbarItem was conditionally added/removed based on isTableTab. NavigationSplitView's NSSplitViewController recalculates the sidebar's top safe-area inset when toolbar items change on the detail column, producing a visible gap shift. Fix: always include the ToolbarItem but hide it on table tabs with opacity(0) + allowsHitTesting(false). This keeps the toolbar layout stable across tab switches, preventing the sidebar inset recalculation. Closes #759 --- .../Views/Toolbar/TableProToolbarView.swift | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/TablePro/Views/Toolbar/TableProToolbarView.swift b/TablePro/Views/Toolbar/TableProToolbarView.swift index 098f3137..f11200fe 100644 --- a/TablePro/Views/Toolbar/TableProToolbarView.swift +++ b/TablePro/Views/Toolbar/TableProToolbarView.swift @@ -162,19 +162,23 @@ struct TableProToolbar: ViewModifier { } } - if !state.isTableTab { - ToolbarItem(placement: .primaryAction) { - Button { actions?.toggleResults() } label: { - Label( - "Results", - systemImage: state.isResultsCollapsed - ? "rectangle.bottomhalf.inset.filled" - : "rectangle.inset.filled" - ) - } - .help(String(localized: "Toggle Results (⌘⌥R)")) - .disabled(state.connectionState != .connected) + // Always include this ToolbarItem to keep the toolbar layout + // stable across tab types. Conditionally adding/removing + // ToolbarItems causes NavigationSplitView to recalculate the + // sidebar's top safe-area inset, producing a visible gap (#759). + ToolbarItem(placement: .primaryAction) { + Button { actions?.toggleResults() } label: { + Label( + "Results", + systemImage: state.isResultsCollapsed + ? "rectangle.bottomhalf.inset.filled" + : "rectangle.inset.filled" + ) } + .help(String(localized: "Toggle Results (⌘⌥R)")) + .disabled(state.connectionState != .connected) + .opacity(state.isTableTab ? 0 : 1) + .allowsHitTesting(!state.isTableTab) } ToolbarItem(placement: .primaryAction) {