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

fix: fix header buttons not pressable when headerTransparent=true & headerMode=float #8804

Merged

Conversation

listiani13
Copy link
Contributor

@listiani13 listiani13 commented Sep 4, 2020

Motivation

Previously when using headerMode="float" with headerTransparent set to true, we cant press header buttons in Android. This PR fixes this. (resolves #8731 )
Been doing some debugging and found out that this is caused by HeaderContainer being set as absolute. Initially it didn't have width & height in Android when it's set to default, that's why we can't access the children.
So, the solution in this PR is to define the height by using headerHeight. But, since we can't access headerHeight from header, Im using local state for keeping up with the headerHeight. Or should I move the HeaderHeight provider out of StackContainer? I'm not sure, since I think it was intended to be kept inside the StackContainer

Test Plan

With this config, now the header button can be clicked. Tested in both platform

  <Stack.Navigator
    headerMode="float"
    screenOptions={{
      headerTransparent: true
    }}
  >
     <Stack.Screen  
      name="Home Screen"
      component={Home}
      />
      <Stack.Screen  
      name="Details Screen"
      component={Details}
      />
  </Stack.Navigator>

Android:

Kapture 2020-09-30 at 19 01 21

iOS:

@netlify
Copy link

netlify bot commented Sep 4, 2020

Deploy preview for react-navigation-example ready!

Built with commit 09160d1

https://deploy-preview-8804--react-navigation-example.netlify.app

@listiani13 listiani13 marked this pull request as ready for review September 4, 2020 13:36
@satya164
Copy link
Member

Thanks for the PR. Can you provide a test plan?

@listiani13
Copy link
Contributor Author

@satya164 just added the test plan :)

@coltonmccormack
Copy link

Thanks for this fix. This was a blocking issue for us to release an update after upgrading navigation.

Copy link

@coltonmccormack coltonmccormack left a comment

Choose a reason for hiding this comment

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

Works great. Passes tests.

@satya164 satya164 force-pushed the fix/unable-to-press-header-icon branch from c995df4 to 09160d1 Compare October 22, 2020 23:49
@satya164 satya164 changed the title fix: unable to press header buttons when headerTransparent set to true and headerMode is float fix: fix header buttons not pressable when headerTransparent=true & headerMode=float Oct 22, 2020
@satya164 satya164 merged commit d6cac67 into react-navigation:main Oct 22, 2020
joshuapinter pushed a commit to cntral/react-navigation that referenced this pull request Sep 29, 2021
…eaderMode=float (react-navigation#8804)

Motivation
--
Previously when using `headerMode="float"` with headerTransparent set to true, we cant press header buttons in Android. This PR fixes this. (resolves react-navigation#8731 )
Been doing some debugging and found out that this is caused by `HeaderContainer` being set as `absolute`. Initially it didn't have width & height in Android when it's set to default, that's why we can't access the children.
So, the solution in this PR is to define the height by using headerHeight. But, since we can't access headerHeight from header, Im using local state for keeping up with the headerHeight. Or should I move the HeaderHeight provider out of StackContainer? I'm not sure, since I think it was intended to be kept inside the StackContainer

Test Plan
--
With this config, now the header button can be clicked. Tested in both platform
```typescript
  <Stack.Navigator
    headerMode="float"
    screenOptions={{
      headerTransparent: true
    }}
  >
     <Stack.Screen  
      name="Home Screen"
      component={Home}
      />
      <Stack.Screen  
      name="Details Screen"
      component={Details}
      />
  </Stack.Navigator>
```

Android:
-
![Kapture 2020-09-30 at 19 01 21](https://user-images.githubusercontent.com/24470609/94682575-5b0fe480-034f-11eb-880a-318643d4eb00.gif)

iOS:
--
<img width="300" src="https://user-images.githubusercontent.com/24470609/94682743-9a3e3580-034f-11eb-8e90-2d31748bde5c.gif" />
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.

cant click on header icons when headerTransparent=true and headerMode="float" in react navigation v5 android
3 participants