-
-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search bar on Android incorrectly adjusts other header elements when open #1450
Comments
I can confirm this issue. Forced me to remove searchHeader completely |
could you find a solution ? |
@EliasBarrera I used the |
Thank you! :D |
You can try to place component on headerRight instead of headerLeft and add marginRight to it : 2022-10-08.at.02-42-44.mp4 |
Talk about a second-class citizen called Android. This still exists... Here's how I've implemented @nrwinner's idea: useLayoutEffect(() => {
navigation.setOptions({
headerSearchBarOptions: {
onOpen: () => {
setIsSearchBarOpen(true)
},
onClose: () => {
setIsSearchBarOpen(false)
},
},
headerLeft: isSearchBarOpen ? () => null : undefined,
headerBackVisible: isSearchBarOpen ? false : true,
headerTitle: isSearchBarOpen ? '' : undefined,
})
}, [navigation, isSearchBarOpen]) |
Hi @nrwinner, thanks for reporting that! Sorry for the really late response 🙏 |
## Description Currently, when user opens the search bar all of the subviews on the toolbar are being pushed to the left. Instead, we want to hide them or even remove them so that they won't be visible during the layout. This PR fixes that problem by secretly hiding the toolbar elements, changing their visibility to `GONE`. Fixes #1450. ## Changes - Added a fix that is being controlled by `handleOpen` and `handleClose` methods in SearchBarView. ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/23281839/8ca8e18e-2cf6-4c04-85c8-51b5d69f1a61 ### After https://github.com/software-mansion/react-native-screens/assets/23281839/41330ea7-a12b-4e14-9a1e-2207a54ebed0 ## Test code and steps to reproduce In our example app open `SearchBar.tsx` and add `headerRight: () => <Button title="Test"/> to the `navigation.setOptions({` declaration. Then launch the app and open `Search bar` example. ## Checklist - [ ] Ensured that CI passes
Hi @nrwinner @garrettg123 @EliasBarrera @wem2017 @hirbod, there's a new version of react-native-screens: 3.26.0 which has this change included. Check it out! If you find something wrong related to the newest version (this change is still buggy or doesn't work for you) let us know 🎉 |
Great, we actually have a use case for this so I am keen to try it |
…-mansion#1903) ## Description Currently, when user opens the search bar all of the subviews on the toolbar are being pushed to the left. Instead, we want to hide them or even remove them so that they won't be visible during the layout. This PR fixes that problem by secretly hiding the toolbar elements, changing their visibility to `GONE`. Fixes software-mansion#1450. ## Changes - Added a fix that is being controlled by `handleOpen` and `handleClose` methods in SearchBarView. ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/23281839/8ca8e18e-2cf6-4c04-85c8-51b5d69f1a61 ### After https://github.com/software-mansion/react-native-screens/assets/23281839/41330ea7-a12b-4e14-9a1e-2207a54ebed0 ## Test code and steps to reproduce In our example app open `SearchBar.tsx` and add `headerRight: () => <Button title="Test"/> to the `navigation.setOptions({` declaration. Then launch the app and open `Search bar` example. ## Checklist - [ ] Ensured that CI passes
Description
On Android, the search bar does not properly adjust header elements.
headerRight
are "pushed" out of the way and to the left of the search barheaderLeft
, both the screen title and said elements are not adjusted at all and appear under the search barScreenshots
Steps To Reproduce
headerSearchBarOptions
headerLeft
navigation optionheaderRight
navigation optionExpected behavior
Actual behavior
headerRight
seem to get "pushed" out of the way to the left of the search barheaderLeft
are not adjusted and appear under the search barReproduction
https://snack.expo.dev/@nrwinner/android-search-bug---react-native-screens-repro
Platform
Workflow
Package versions
The text was updated successfully, but these errors were encountered: