Fix navigation title overlapping with SearchBar in SearchSheetView#142
Conversation
3943020 to
b516fa6
Compare
|
@aaronbrethorst , would love if you could review the changes whenever you get time! The tests are failing in TripPlannerViewModelTests.swift, which I think was pre-existing since I only modified SearchSheetView. |
aaronbrethorst
left a comment
There was a problem hiding this comment.
Thanks for taking this on, Mayukh! The before/after videos clearly demonstrate the issue and the fix. The approach of using a custom header instead of the system navigation bar title is a reasonable solution to the overlap problem.
Thanks for calling my attention to the flaky test. I've addressed that separately in PR #145.
Important
Use Modern Navigation Bar API
File: SearchSheetView.swift:65
The modifier .navigationBarHidden(true) is deprecated as of iOS 16. Since OTPKit targets iOS 18+, please use the modern API:
// Current (deprecated)
.navigationBarHidden(true)
// Replace with
.toolbar(.hidden, for: .navigationBar)Fit and Finish
Add Accessibility Trait for Custom Header
File: SearchSheetView.swift:29-33
When replacing the native .navigationTitle() with a custom Text view, VoiceOver users lose the automatic "header" announcement. Add the accessibility trait to maintain the same experience:
Text(buildNavigationTitle())
.font(.headline)
.padding(.top, 20)
.padding(.bottom, 12)
.frame(maxWidth: .infinity)
.accessibilityAddTraits(.isHeader) // Add this lineNotes
- Wrapping the default view content in a
ScrollViewis a good improvement for content management. - The keyboard handling with
.ignoresSafeArea(.keyboard, edges: .bottom)is a nice addition.
b516fa6 to
5c95c71
Compare
|
Made the required changes! |
aaronbrethorst
left a comment
There was a problem hiding this comment.
Hey Mayukh, thanks for iterating on this UI fix for the SearchSheetView navigation title overlap. I appreciate you addressing my earlier feedback about the deprecated API and the accessibility trait—those changes look great. We're almost there, but I need one more change before we can merge this.
Critical
Add Cancel Button for Sheet Dismissal Consistency
File: SearchSheetView.swift
By hiding the navigation bar entirely with .toolbar(.hidden, for: .navigationBar), the sheet no longer has a visible Cancel/Close button. This breaks consistency with other sheets in the codebase. Looking at LocationOptionsSheet.swift:63-66 and AdvancedOptionsSheet.swift:32-35, both follow this pattern:
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button("Cancel") { dismiss() }
}
}While users can still swipe down to dismiss, having a visible button is important for:
- Consistency: All other modal sheets in OTPKit provide a Cancel button
- Discoverability: Not all users know they can swipe to dismiss
- Accessibility: VoiceOver users benefit from an explicit dismiss action
The fix is to add a Cancel button to your custom header, similar to how the other sheets implement it. You'll need to add @Environment(\.dismiss) var dismiss and include a cancel button in your header VStack.
Thanks again, and I look forward to merging this once the Cancel button is added!
5c95c71 to
b159db1
Compare
|
Thanks for the feedback! Have implemented the cancel button too alongside. |
There was a problem hiding this comment.
Hey Mayukh, you've done great work iterating on this UI fix for the SearchSheetView navigation title overlap. You addressed all my feedback—the modern .toolbar(.hidden, for: .navigationBar) API, the accessibility header trait, and the Cancel button for dismissal consistency. The before/after videos clearly demonstrated the issue and your solution.
There's nothing left to change—this PR is ready to merge. Thanks for your patience working through the rounds of review!
Summary
Fixes #141
This PR resolves the UI issue where the navigation title ("Choose Start" / "Choose Destination") was overlapping with the SearchBar in SearchSheetView.
Key Changes in SearchSheetView.swift
.navigationTitle()and.navigationBarTitleDisplayMode(.inline)modifiers.navigationBarHidden(true)to prevent the empty navigation bar from taking up space.ignoresSafeArea(.keyboard, edges: .bottom)to prevent keyboard from pushing content off-screenOutcomes
Video (Before, also observe the top of the sheet)
github1.mp4
Video (After, observe the top of the sheet now!)
github2.mp4