react-navigation / react-navigation

Routing and navigation for your React Native apps
https://reactnavigation.org
23.3k stars 4.97k forks source link

fix: setting headerBackTitleVisible to false not working on iOS #11937

Closed zetavg closed 6 days ago

zetavg commented 1 month ago

Motivation

According to the docs, setting headerBackTitleVisible to false should hide the back title on iOS, while this is not the case with react-native-screens v3.29+.

Cause

With the current code, backTitle={headerBackTitleVisible ? headerBackTitle : ' '}, the back title is set to a blank string if headerBackTitleVisible is false. However, in newer versions of react-native-screens, the backTitle will be considered blank if it only contains white spaces, making it fallback to the default title - which makes the back title not hidden at all.

Fix

Assign the backTitleVisible property of RNSScreenStackHeaderConfig native component, which seems to be a legit way to hide the back title.

Test plan

  1. Create a native stack navigator with the backTitleVisible screen option set to false.
  2. See if the back title is hidden on iOS when navigating to another screen.
Expected Not Expected
github-actions[bot] commented 1 month ago

Hey @zetavg! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our contribution guidelines.

netlify[bot] commented 1 month ago

Deploy Preview for react-navigation-example ready!

Name Link
Latest commit 2573816a7467edf7ebf283e2e4051f4ee128ac12
Latest deploy log https://app.netlify.com/sites/react-navigation-example/deploys/6641d37941fbc800087616dc
Deploy Preview https://deploy-preview-11937--react-navigation-example.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

codecov-commenter commented 6 days ago

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 77.00%. Comparing base (d90ed76) to head (84cca6c). Report is 2 commits behind head on main.

Files Patch % Lines
packages/native-stack/src/views/HeaderConfig.tsx 33.33% 1 Missing and 1 partial :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #11937 +/- ## ========================================== - Coverage 77.03% 77.00% -0.03% ========================================== Files 210 210 Lines 6339 6341 +2 Branches 2506 2508 +2 ========================================== Hits 4883 4883 - Misses 1402 1403 +1 - Partials 54 55 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.