question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Search bar on Android incorrectly adjusts other header elements when open

See original GitHub issue

Description

On Android, the search bar does not properly adjust header elements.

  • Elements placed via headerRight are “pushed” out of the way and to the left of the search bar
  • If there are any elements placed via headerLeft, both the screen title and said elements are not adjusted at all and appear under the search bar

Screenshots

Screen Shot 2022-05-17 at 10 33 52 AM Screen Shot 2022-05-17 at 10 34 05 AM

Steps To Reproduce

  1. Add a search bar to the header by specifying headerSearchBarOptions
  2. Add any element(s) via the headerLeft navigation option
  3. (Optional) Add any elements to the headerRight navigation option
  4. Open the search bar on android

Expected behavior

  • The header buttons on both the left side and the right side should no longer be visible.
  • The search bar should appear as the only element in the header.
  • The input should be unobstructed.

Actual behavior

  • Any elements placed via headerRight seem to get “pushed” out of the way to the left of the search bar
  • The screen title as well as any elements placed by headerLeft are not adjusted and appear under the search bar

Reproduction

https://snack.expo.dev/@nrwinner/android-search-bug---react-native-screens-repro

Platform

  • iOS
  • Android
  • Web
  • Windows
  • tvOS

Workflow

  • Managed workflow
  • Bare workflow

Package versions

package version
react-native 0.68.1
@react-navigation/native 6.0.2
@react-navigation/native-stack 6.1.0
react-native-screens 3.13.1
react-native-safe-area-context 4.2.4
expo 45.0.0

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
hirbodcommented, May 27, 2022

I can confirm this issue. Forced me to remove searchHeader completely

0reactions
mazurGitcommented, Oct 7, 2022

You can try to place component on headerRight instead of headerLeft and add marginRight to it : const {width} = Dimensions.get(‘screen’); … headerRight:() => <FiltersHeader contentContainerStyle={{marginRight: width - 110}} />

https://user-images.githubusercontent.com/69375560/194675879-283f5e0a-478b-439e-bda7-ea160f3fb689.mp4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toolbar overlapping below status bar - android - Stack Overflow
Use android:fitsSystemWindows="true" in the root view of your layout (LinearLayout in your case).
Read more >
12 fast fixes for common Android problems - Computerworld
Solve annoying issues and get any phone in tip-top shape with these easy-to-implement, expert-approved solutions.
Read more >
Handling common HTML and CSS problems - MDN Web Docs
Use this page, or another site that has a prominent heading or other block-level element. Right/Cmd + click on the element in question...
Read more >
Security tips - Android Developers
The most common security concern for an application on Android is whether the data that you save on the device is accessible to...
Read more >
Content Jumping (and How To Avoid It) | CSS-Tricks
It's especially common with ads but can happen with any layout-affecting content that loads after initial render, including images or even fonts ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found