Skip to content

Conversation

@kligarski
Copy link
Contributor

Description

Fixes missing search bar on root screen on iOS 26. (Part of https://github.com/software-mansion/react-native-screens-labs/issues/331).

The search bar is missing on root screen on iOS 26 beta 4 (only on iPhones). I wasn't able to reproduce this issue in bare UIKit app.

I found that on iOS 26, there are new properties for search bar, including searchBarPlacementAllowsToolbarIntegration. Setting this prop to false fixes the issue. I am not 100% sure what is the intended use case for this prop. If I understand correctly (but I might be wrong here), if this is set to true and preferredSearchBarPlacement is set to integrated or integratedButton, then you can use search bar button from searchBarPlacementBarButtonItem to place it inside toolbarItems in a position you want, but in our case, both preferredSearchBarPlacement and searchBarPlacement are set to UINavigationItemSearchBarPlacementStacked so this does not add up.

This might be a bug because even in the most recent release notes for iOS 26 beta 4, some workarounds connected to this prop are mentioned:

UIKit
Known Issues

In apps using UIToolbar, the Search bar sometimes does not respond to taps and displays without the magnifying glass, dictation button, or placeholder text. (151126350)

Workaround: Quit the app then re-launch it.

On iPhone only, the searchTextField property of a UISearchBar belonging to a UISearchController (i.e. searchController.searchBar.searchTextField) might not return the same instance when called at different times. (153550157)

Workaround: Look for UISearchBar or UISearchController API equivalent to the UISearchTextField API you’re using. If none can be found, you can prevent the issue by setting the UINavigationItem.searchBarPlacementAllowsToolbarIntegration property to false on the navigation item the search controller has been assigned to.

On iPhone, the search bar might be missing from a tab’s navigation bar due to usual client code timing of assembling the view controller hierarchy. (156174227)

Workaround: Set the searchBarPlacementAllowsToolbarIntegration property of the UINavigationItem to false at the same time you set the searchController.

Changes

  • set searchBarPlacementAllowsToolbarIntegration to NO

Screenshots / GIFs

before after
before_searchbar.mov
after_searchbar.mov

Test code and steps to reproduce

Run Test758. You should be able to use search bar on the root screen.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@kligarski kligarski requested a review from kkafar August 5, 2025 10:35
@kligarski
Copy link
Contributor Author

Created a ticket for the future to look into whether this fix is necessary: https://github.com/software-mansion/react-native-screens-labs/issues/338.

@kligarski
Copy link
Contributor Author

Still necessary on iOS 26 beta 5.

Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

I would just add the comment & if this workaround works -> let's go with it.

@kligarski kligarski merged commit d0c4c82 into main Aug 6, 2025
6 checks passed
@kligarski kligarski deleted the @kligarski/fix-search-bar-on-root-screen-ios-26 branch August 6, 2025 11:11
kkafar pushed a commit that referenced this pull request Sep 2, 2025
…ation with toolbar (#3168)

## Description

This PR addresses changes to search bar on iOS 26.

Closes
software-mansion/react-native-screens-labs#339.

After merging, docs in `react-navigation` should also be updated, issue
for this:
software-mansion/react-native-screens-labs#384.

## Changes

- add support for new search bar placements (`integrated`,
`integratedButton`, `integratedCentered`),
- add prop for controlling new search bar toolbar integration on iPhone
(`allowToolbarIntegration`),
- deprecate one of the placements (`inline` has been renamed to
`integrated` starting from iOS 26) and `cancelButtonText` (search cancel
button does not have any text on iOS 26),
- reduce scope of workaround introduced in
#3098 (only
to `stacked` placement)
- disable recycling for `SearchBar` (workaround above does not solve all
bugs with search bar on iOS 26).

## Screenshots / GIFs


https://github.com/user-attachments/assets/bcbb86e1-298d-4942-a290-3acdaef4214d

> [!NOTE]
> If you use `integrated`, `integratedButton` or `integratedCentered`,
the integration into toolbar is delayed and causes a flash (you can see
it on the video). This bug happens also in bare UIKit app. The best
workarounds I could find are:
> - use `automatic` with transparent header,
> - use `automatic` with `hideWhenScrolling: true`
>
> Details:
software-mansion/react-native-screens-labs#331 (comment)
>
> There is also another bug (also reproducible but due to how
tabs+freeze work in screens, it's a little bit worse in our case). I
think it's more of an edge case though (if you use tab with search
systemItem but disable toolbar integration, the search bar is empty).
Details:
software-mansion/react-native-screens-labs#331 (comment)

## Test code and steps to reproduce

Run `Test3168`. You can also see other Search Bar related test screens
like `SearchBar.tsx`, `Test758`, `Test1097`.

## Checklist

- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [x]
https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [x]
https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ]
https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes
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.

3 participants