Skip to content

Conversation

@kligarski
Copy link
Contributor

@kligarski kligarski commented Nov 17, 2025

Description

Fixes header height values reported via onHeaderHeightChange event.

Fixes #3040.
Fixes #2661.

Note

Due to incorrect values being reported previously, there are some workarounds in react-navigation's NativeStackView.native.tsx. Those should be redundant now and we should clean-up that code when this PR is merged. We intend to handle backward compatibility through a flag. PR in react-navigation: react-navigation/react-navigation#12852.

before after
before3402.mp4
after3402.mp4

Changes

  • report height of the header instead of Screen's top offset
  • convert px to dp
  • update TestHeaderHeight to allow testing dynamic changes to the prop and react-navigation's useHeaderHeight() hook

Test code and steps to reproduce

Run TestHeaderHeight.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

@kligarski kligarski marked this pull request as ready for review November 17, 2025 09:46
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backward compat can be handled via compatibilityFlags in src/flags.ts. This is how we've done it in react navigation so far.

You add a flag there, denoting that a change has been introduced & then try to read it in react navigation. If it is not present or false, you assume old implementation & if it is present & enabled you assume new one.

Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I've left few remarks.

@kligarski kligarski self-assigned this Nov 19, 2025
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The useHeaderHeight hook doesnt work on Android? useHeaderHeight returns incorrect value for native stack on Android

3 participants