From a49cc479367aa9ccd888b6d716e624d089e2e23a Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Fri, 10 Oct 2025 13:58:57 +0300 Subject: [PATCH] Prevent the system from automatically hiding the sidebar when backgrounding the app --- .../Application/Navigation/NavigationCoordinators.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift index 71b97d90d..0f58158bc 100644 --- a/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift +++ b/ElementX/Sources/Application/Navigation/NavigationCoordinators.swift @@ -329,6 +329,7 @@ private struct NavigationSplitCoordinatorView: View { @State private var columnVisibility = NavigationSplitViewVisibility.all @Environment(\.horizontalSizeClass) private var horizontalSizeClass + @Environment(\.scenePhase) private var scenePhase @Bindable var navigationSplitCoordinator: NavigationSplitCoordinator @@ -352,6 +353,12 @@ private struct NavigationSplitCoordinatorView: View { module.coordinator?.toPresentable() .id(module.id) } + .onChange(of: columnVisibility) { oldValue, _ in + // Preserve the current column visibility when backgrounding the app + if scenePhase == .background { + columnVisibility = oldValue + } + } .ignoresSafeArea() // Necessary when embedded in a TabView on iPadOS otherwise there's a gap at the top (as of 18.5). }