From e339faaca5f8814a970f82cbff34925830a1a34a Mon Sep 17 00:00:00 2001 From: Bosco Ho Date: Tue, 19 Sep 2023 03:42:41 -0700 Subject: [PATCH] - Fix issue where ScrollToView onDisappear doesn't get called. --- Mlem/Views/Shared/ScrollToView.swift | 40 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/Mlem/Views/Shared/ScrollToView.swift b/Mlem/Views/Shared/ScrollToView.swift index 85ab445d6..9ea37aa04 100644 --- a/Mlem/Views/Shared/ScrollToView.swift +++ b/Mlem/Views/Shared/ScrollToView.swift @@ -17,15 +17,18 @@ struct ScrollToView: View { @Binding var appeared: Bool var body: some View { - HStack(spacing: 0) { - EmptyView() - } - .frame(height: 1) - .onAppear { - appeared = true - } - .onDisappear { - appeared = false + /// We don't have any horizontal scroll views yet, but this may need to be a LazyHStack if we do. [2023.09] + LazyVStack(spacing: 0) { + HStack(spacing: 0) { + EmptyView() + } + .frame(height: 1) + .onAppear { + appeared = true + } + .onDisappear { + appeared = false + } } } } @@ -38,13 +41,16 @@ struct ListScrollToView: View { @Binding var appeared: Bool var body: some View { - EmptyView() - .frame(height: 1) - .onAppear { - appeared = true - } - .onDisappear { - appeared = false - } + /// We don't have any horizontal scroll views yet, but this may need to be a LazyHStack if we do. [2023.09] + LazyVStack(spacing: 0) { + EmptyView() + .frame(height: 1) + .onAppear { + appeared = true + } + .onDisappear { + appeared = false + } + } } }