react-native-screens icon indicating copy to clipboard operation
react-native-screens copied to clipboard

Swiping back while header search input is focused breaks navigation options

Open MaxAst opened this issue 5 months ago • 3 comments

Description

When you navigate back with a swipe gesture, while the header search bar input is focused

  1. the header on the given screen disappears during the back navigation
  2. the header options of the screen that we navigate back to are reset. E.g. in this case, (tabs) has headerShown set to false. However, if we navigate back from the search screen while the search input was focused, the header title is now incorrectly shown as "(tabs)".

Note that this issue only happens when the header search input is focused. If we navigate back using the native back button or if we swipe back when the input is not focused, the bug does not occur.

https://github.com/user-attachments/assets/fe3356eb-7a44-4357-8efd-8aeb3d2b7c19

Steps to reproduce

  1. Run the repro in Expo Go
  2. Press on "Go to search" on the first screen
  3. Focus the header search input
  4. While focused, apply the "go back" gesture by swiping right from the left edge of the screen
  5. During the swipe gesture, you'll notice that the header in the search screen disappears and the content jumps up
  6. Once the navigation is complete, you'll notice that the (tabs) header title is shown, even though the (tabs) navigator options set headerShown to false

Snack or a link to a repository

https://github.com/MaxAst/react-native-screens-search-repro

Screens version

4.11.1

React Native version

0.79.2

Platforms

iOS

JavaScript runtime

Hermes

Workflow

Expo managed workflow

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

Real device

Device model

iPhone 16 Pro Max

Acknowledgements

Yes

MaxAst avatar Jun 16 '25 06:06 MaxAst

Hey! Thanks for the report, we'll look into this

kkafar avatar Jun 16 '25 12:06 kkafar

Facing the same issue. Also, the search text is persisted on other screens having headerSearchOptions

faljabi avatar Jun 16 '25 15:06 faljabi

@kkafar also worth mentioning that the screens in the repro are siblings in a native stack navigator. I believe this workaround only works if we navigate from a child to a parent screen.

MaxAst avatar Jun 17 '25 06:06 MaxAst