Skip to content

Fix navigation title overlapping with SearchBar in SearchSheetView#142

Merged
aaronbrethorst merged 1 commit intoOneBusAway:mainfrom
mayukhbaidya18:fix/searchsheetview-navigation-title-overlap
Jan 31, 2026
Merged

Fix navigation title overlapping with SearchBar in SearchSheetView#142
aaronbrethorst merged 1 commit intoOneBusAway:mainfrom
mayukhbaidya18:fix/searchsheetview-navigation-title-overlap

Conversation

@mayukhbaidya18
Copy link
Contributor

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

  1. Removed navigation bar title: Removed .navigationTitle() and .navigationBarTitleDisplayMode(.inline) modifiers
  2. Added custom header: Implemented title as a Text view within the VStack at the top of the sheet
  3. Hidden navigation bar: Used .navigationBarHidden(true) to prevent the empty navigation bar from taking up space
  4. Added keyboard handling: Used .ignoresSafeArea(.keyboard, edges: .bottom) to prevent keyboard from pushing content off-screen
  5. Improved scrollability: Wrapped default view content in ScrollView for better content management

Outcomes

  • No more title/TextField overlap
  • Proper spacing and layout
  • Better keyboard handling

Video (Before, also observe the top of the sheet)

github1.mp4

Video (After, observe the top of the sheet now!)

github2.mp4

@mayukhbaidya18 mayukhbaidya18 force-pushed the fix/searchsheetview-navigation-title-overlap branch from 3943020 to b516fa6 Compare January 20, 2026 10:46
@mayukhbaidya18
Copy link
Contributor Author

@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.

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 line

Notes

  • Wrapping the default view content in a ScrollView is a good improvement for content management.
  • The keyboard handling with .ignoresSafeArea(.keyboard, edges: .bottom) is a nice addition.

@mayukhbaidya18 mayukhbaidya18 force-pushed the fix/searchsheetview-navigation-title-overlap branch from b516fa6 to 5c95c71 Compare January 29, 2026 06:48
@mayukhbaidya18
Copy link
Contributor Author

Made the required changes!

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@mayukhbaidya18 mayukhbaidya18 force-pushed the fix/searchsheetview-navigation-title-overlap branch from 5c95c71 to b159db1 Compare January 30, 2026 12:37
@mayukhbaidya18
Copy link
Contributor Author

Thanks for the feedback! Have implemented the cancel button too alongside.

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@aaronbrethorst aaronbrethorst merged commit 7a2a674 into OneBusAway:main Jan 31, 2026
3 checks passed
@mayukhbaidya18 mayukhbaidya18 deleted the fix/searchsheetview-navigation-title-overlap branch February 1, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Navigation title overlapping with SearchBar in SearchSheetView

2 participants