Fix a layout loop.

This commit is contained in:
Doug
2026-07-31 12:24:19 +01:00
committed by Doug
parent 7c245acaaf
commit ad38d9698a
2 changed files with 12 additions and 1 deletions
@@ -335,7 +335,7 @@ extension EnvironmentValues {
}
private struct NavigationSplitCoordinatorView: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Environment(\.tabViewHorizontalSizeClass) private var horizontalSizeClass
@Environment(\.scenePhase) private var scenePhase
@Bindable var navigationSplitCoordinator: NavigationSplitCoordinator
@@ -297,6 +297,16 @@ import SwiftUI
}
}
extension EnvironmentValues {
/// The horizontal size class of the ``NavigationTabCoordinatorView`` that contains this view.
/// This provides a stable value regardless of whether the ``TabRailView`` is in the layout hierarchy.
///
/// The rail consumes width and can cause a layout loop with the ``NavigationSplitCoordinatorView``
/// when the split becomes compact, hides the rail but then has enough space to become regular and so
/// attempts to show the rail etc.
@Entry var tabViewHorizontalSizeClass: UserInterfaceSizeClass?
}
private struct NavigationTabCoordinatorView<Tag: Hashable>: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@@ -308,6 +318,7 @@ private struct NavigationTabCoordinatorView<Tag: Hashable>: View {
var body: some View {
tabView
.environment(\.tabViewHorizontalSizeClass, horizontalSizeClass)
.sheet(item: $navigationTabCoordinator.sheetModule) { module in
module.coordinator?.toPresentable()
.id(module.id)