Skip to content
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

navigationBarColor props breaking safeArea / textinput & more #1719

Closed
pierroo opened this issue Feb 18, 2023 · 9 comments · Fixed by #1988
Closed

navigationBarColor props breaking safeArea / textinput & more #1719

pierroo opened this issue Feb 18, 2023 · 9 comments · Fixed by #1988
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android

Comments

@pierroo
Copy link

pierroo commented Feb 18, 2023

Description

Seems like the issue I posted here: react-navigation/react-navigation#11139
is actually due to react native screens, so I will post the bug here instead.

On android, when using react navigation, adding navigationBarColor in the screenOptions of a @react-navigation/native-stack will completely mess up the display of the app.

TextInput will no longer be pulled up above the keyboard and the view doesn't adjust naturally

SafeAreaView turns out messed up and needs to be manually added on some screens, while removed on others and it seems random.

Steps to reproduce

Have a basic native-stack, with a basic screen, use the screen option navigationBarColor on it, and see the whole display being messed up.

Snack or a link to a repository

https://reactnavigation.org/docs/native-stack-navigator

Screens version

3.18.2

React Native version

0.69.7

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Missing repro This issue need minimum repro scenario labels Feb 18, 2023
@github-actions
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@naufaladi
Copy link

naufaladi commented Mar 9, 2023

I also have this issue. The app would continue to draw the screen view "behind" the navigationBar. Even the RN "debug/ warning" pop up would be drawn behind the navigationBar.

I have tried to temporarily "solve" this by manually adding marginBottom to my topmost view (screenHeight - windowsHeight - statusBarHeight), but i don't think it's a very good solution due to unforeseen consequences from this bug.

This is the simplest example to reproduce said bug:
image

To clearly see the bug, make the screen to display a long list of items, you will notice that the bottom most items would only be partially shown and/or is behind the navigationBar.

Including or excluding the navigationBarHidden: false produce the same result.
Using safeAreaView on the screen produce the same result

@LukasMod
Copy link

I have the same problem. Adding navigationBarColor breaks KeyboardAvoidingView that worked well before with TextInput. It was a big surprise that a color setting could mess things up

"react-native": "0.71.1",
"@react-navigation/bottom-tabs": "^6.5.3",
"@react-navigation/native": "^6.1.2",
"@react-navigation/native-stack": "^6.9.8",
"@react-navigation/stack": "^6.3.11",

@arthur5005
Copy link

Wondering if anyone has a work around.

Experiencing exactly this. It's not the end of the world if the app doesn't bleed to the edges with the color I want, but trying to work around this with manual adjustments has a very obvious pitfalls.

Thanks again for all the hard work everyone, I get what it takes to maintain a package like this.

@matt-dalton
Copy link

I'm also getting this - took me a while to figure out what was messing up the layouts so thanks for the issue!

@MihailsKostjuks
Copy link

the same problem. SafeAreaView just not working with navigationBarColor... bottom: 0 starts from bottom of nav bar since this moment. How to play around it????

@kyle-belle
Copy link

I am having the same issue as well. I suspect this is a deeper problem in android. I think what this lib is trying to do is make the real nav bar transparent and cover up that area with the color we provide (could be wrong tho). Couple months ago when i was using another package react-native-navigation-bar-color wheneven i would set the nav bar to transparent (or any value with transparency for that matter) it always have the buggy behaviour but solid colors work fine.

For now a solution (if you don't mind installing the library) is to install react-native-navigation-bar-color and change the nav bar color with that

@scarlac
Copy link

scarlac commented Dec 8, 2023

The workaround is to install Expo's "NavigationBar" module, which is specific to Android, and can fix this issue:

npx expo install expo-navigation-bar

Then remove your use of navigationBarColor: "red" from all your navigators and replace it with calls to:

import * as NavigationBar from 'expo-navigation-bar';
// ...
NavigationBar.setBackgroundColorAsync('red');

Yes, the culprit is indeed when you set the following code:

<AppSwitcherStack.Navigator
  initialRouteName={initialRouteName}
  screenOptions={{
    header: (props) => <MyHeader {...props} />,
    navigationBarColor: 'red', // remove this - causes statusbar and navigationbar to become overlays/take no space
  }}
/>

The Expo module does not have this issue. I peeked the code for react-native-screens and I don't fully understand why the statusbar and navigationbar would change like it does, but it's clear that it does.

@jiyong1
Copy link
Contributor

jiyong1 commented Dec 12, 2023

Please check this PR #1988

tboba pushed a commit that referenced this issue Dec 21, 2023
…tionBarHidden (#1988)

## Description

Currently when user tries to change the appearance of the navigation bar
(using navigationBarHidden / navigationBarColor props) the content of
the screen jumps to the place that does not respect safeAreaView. This
PR fixes it by removing `decorFitsSystemWindow` declaration, as it
breaks the interface by matching it to `fit system window`.

Resolves #1719.

## Changes

- Removed `decorFitsSystemWindow` call from `ScreenWindowTraits.kt`

## Checklist

- [X] Ensured that CI passes
alduzy added a commit that referenced this issue Jun 3, 2024
## Description

Once upon a time there was an
[issue](#1719)
regarding navigation bar. The problem was that the background color set
to the navigation bar covered the content behind, see examples:

<table>
<tr>
<th>navigationBarColor: 'transparent'</th>
<th>navigationBarColor: 'yellow'</th>
</tr>
<tr>
<td>

![Screenshot 2024-05-22 at 10 33
28](https://github.com/software-mansion/react-native-screens/assets/91994767/eb3ea5a5-4617-4547-a052-ab0612872697)

</td>
<td>

![Screenshot 2024-05-22 at 10 34
08](https://github.com/software-mansion/react-native-screens/assets/91994767/805fa199-b90c-40aa-9ef5-b5ab8abef71a)

</td>
</tr>
</table>

Then [PR
1988](#1988)
solved the issue, but introduced another problem: sometimes it may be
intended to have content behind the navigation bar.

<table>
<tr>
<th>navigationBarColor: 'transparent' after PR 1988</th>
<th>navigationBarColor: 'transparent' before PR 1988</th>
</tr>
<tr>
<td>

![Screenshot 2024-05-21 at 13 00
23](https://github.com/software-mansion/react-native-screens/assets/91994767/76ec2fa1-e212-4725-a1da-32bcf8c5eb84)

</td>
<td>

![Screenshot 2024-05-21 at 13 07
19](https://github.com/software-mansion/react-native-screens/assets/91994767/8fa15e57-7168-4fec-b8e7-3cce29eeebdc)

</td>
</tr>
</table>

This PR intents to add a new screen option, enabling navigation bar
translucency control, so that the developers can decide if they want to
show content behind the navigation bar independently.

Fixes #2122 #1719

## Changes

- added navigationBarTranslucent option

## Test code and steps to reproduce

<!--
Please include code that can be used to test this change and short
description how this example should work.
This snippet should be as minimal as possible and ready to be pasted
into editor (don't exclude exports or remove "not important" parts of
reproduction example)
-->

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation: <!-- For adding new props to native-stack
-->
- [ ]
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
- [ ]
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
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android
Projects
None yet
9 participants