diff --git a/clients/shared/DesignSystem/Modifiers/BottomAlignedMinHeightLayout.swift b/clients/shared/DesignSystem/Modifiers/BottomAlignedMinHeightLayout.swift index 6c7b594e32a..38dadc472d2 100644 --- a/clients/shared/DesignSystem/Modifiers/BottomAlignedMinHeightLayout.swift +++ b/clients/shared/DesignSystem/Modifiers/BottomAlignedMinHeightLayout.swift @@ -46,6 +46,28 @@ public struct BottomAlignedMinHeightLayout: Layout { proposal: ProposedViewSize(width: childSize.width, height: childSize.height) ) } + + // MARK: - Alignment (opt out of default cascade) + + /// Returns `nil` to opt out of the default guide-merging cascade. + /// + /// The default `Layout` protocol implementation iterates every subview + /// and recursively queries their alignment guides — O(n × depth). When + /// this layout wraps the entire LazyVStack scroll content, the cascade + /// walks every visible cell, producing multi-second hangs. + /// + /// Returning `nil` tells ancestors "no explicit guide value; use default + /// positioning", which is correct because this layout positions its + /// child via `placeSubviews`, not alignment guides. + /// + /// Reference: [Layout.explicitAlignment](https://developer.apple.com/documentation/swiftui/layout/explicitalignment(of:in:proposal:subviews:cache:)-8ofeu) + public func explicitAlignment(of guide: HorizontalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGFloat? { + nil + } + + public func explicitAlignment(of guide: VerticalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGFloat? { + nil + } } extension View { diff --git a/clients/shared/DesignSystem/Modifiers/WidthCapLayout.swift b/clients/shared/DesignSystem/Modifiers/WidthCapLayout.swift index 016cb1f3b14..8c90f64a37e 100644 --- a/clients/shared/DesignSystem/Modifiers/WidthCapLayout.swift +++ b/clients/shared/DesignSystem/Modifiers/WidthCapLayout.swift @@ -29,6 +29,25 @@ public struct WidthCapLayout: Layout { proposal: ProposedViewSize(width: bounds.width, height: bounds.height) ) } + + // MARK: - Alignment (opt out of default cascade) + + /// Returns `nil` to opt out of the default guide-merging cascade. + /// + /// The default `Layout` protocol implementation iterates every subview + /// and recursively queries their alignment guides — O(n × depth). + /// Returning `nil` tells ancestors "no explicit guide value; use default + /// positioning", which is correct because this layout positions its + /// child via `placeSubviews`, not alignment guides. + /// + /// Reference: [Layout.explicitAlignment](https://developer.apple.com/documentation/swiftui/layout/explicitalignment(of:in:proposal:subviews:cache:)-8ofeu) + public func explicitAlignment(of guide: HorizontalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGFloat? { + nil + } + + public func explicitAlignment(of guide: VerticalAlignment, in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGFloat? { + nil + } } extension View {