diff --git a/damus/Views/Onboarding/OnboardingSuggestionsView.swift b/damus/Views/Onboarding/OnboardingSuggestionsView.swift index 3a4eb307..773e22c1 100644 --- a/damus/Views/Onboarding/OnboardingSuggestionsView.swift +++ b/damus/Views/Onboarding/OnboardingSuggestionsView.swift @@ -19,7 +19,7 @@ struct OnboardingSuggestionsView: View { let first_post_examples: [String] = [first_post_example_1, first_post_example_2, first_post_example_3, first_post_example_4] let initial_text_suffix: String = "\n\n#introductions" - @Environment(\.presentationMode) private var presentationMode + @Environment(\.dismiss) var dismiss func next_page() { withAnimation { @@ -58,6 +58,12 @@ struct OnboardingSuggestionsView: View { placeholder_messages: self.first_post_examples, initial_text_suffix: self.initial_text_suffix ) + .onReceive(handle_notify(.post)) { _ in + // NOTE: Even though PostView already calls `dismiss`, that is not guaranteed to work under deeply nested views. + // Thus, we should also call `dismiss` from here (a direct subview of a sheet), which is explicitly supported by Apple. + // See https://github.com/damus-io/damus/issues/1726 for more context and information + dismiss() + } .tag(1) } .tabViewStyle(.page(indexDisplayMode: .never)) diff --git a/damus/Views/PostView.swift b/damus/Views/PostView.swift index 35573839..5b70c951 100644 --- a/damus/Views/PostView.swift +++ b/damus/Views/PostView.swift @@ -85,16 +85,12 @@ struct PostView: View { self.initial_text_suffix = initial_text_suffix } - @Environment(\.presentationMode) var presentationMode + @Environment(\.dismiss) var dismiss func cancel() { notify(.post(.cancel)) dismiss() } - - func dismiss() { - self.presentationMode.wrappedValue.dismiss() - } func send_post() { let refs = references.filter { ref in