-
-
Notifications
You must be signed in to change notification settings - Fork 527
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
headerRight randomly position the component incorrectly #432
Comments
I cannot repro your issue either on a simulator or physical device. Upgrade packages to the newest version. Is the issue still present then? If so, please try to write which steps to take for the issue to occur. |
Yes, I just tried again and the issue is still present. I did a fresh install and the issue persisted. Have you tried the repo I've sent? The steps are simple:
To create the stack I am using I created a snack to reproduce but also not being able to make it happen there: The thing is, I am using a stack created by I wanted to have parts of my app using the native stack for more simple screens where I don't need to manipulate the header too much, and others the js based stack so I can migrate incrementally. Is that an issue or should work fine? |
I cloned your project and also made a bare react-native project. The issue exists only while opening it through Expo Client. This means that the version of RNScreens in the current Expo Client is having the bug since it has RNScreens in version 2.0.0-alpha.12. Can you repro it that way to prove if it is right? |
@lnmunhoz can I close it then? Is your issue solved? |
Let me try to reproduce one more time so we can figure out why it was happening. I will update here in a couple hours. |
This is happens in bare RN project as well, so I doubt it has anything to do with Expo |
@Deepp0925 does it happen with the newest RNScreens version: 2.4.0? |
Yes sir |
I have a workaround if it's a blocker for anyone here react-navigation/react-navigation#6746 (comment):
|
I can also confirm that this bug still happens on |
Hey @WoLewicki, do you want me to setup a sample project, showing this issue? Here's some screenshots demonstrating the problem: This first one, is just adding a 44x44 Touchable button as the If I inspect the element, you can see it's 44x44: If I add a Now if I inspect the element, you can see it's only It feels like this extra |
Using a custom compontent in headerCenter is affected by the same bug/problem... |
same for me |
This happens almost everytime I start the app, this really should be fixed. |
I believe it is the same issue as #322. Can you try the workaround submitted there and see if it works correctly? |
same for me |
same for me too |
This is happening to me also with headerCenter and headerRight only in iOS, my custom component is wrongly positioned. |
Same here using |
+1 |
@tboba I get it on the |
I'm also getting this issue on Expo Router ~3.4.7 (SDK 50.0.0). It went away for me when moving more logic about the header into the layout instead of setting it on mount in the useEffect hook. Like this:
Might work for some of you! |
I was unable to reproduce the issue with the latest version, tried with Expo Go, Expo prebuild, Bare RN. If the problem still persists with the latest version please attach a working repro. |
## Description This PR gets rid of undesired white flashes during `maybeAddToParentAndUpdateContainer`. The white flash was present on paper architecture when `unmountOnBlur` option was set to true on parent bottomStackNavigator (see repro). The affected logic was previously introduced or changed by following PRs: - #600 - #613 - #643 The removed `_hasLayout` was initially added by #600 in order to resolve an issue: #432. However the logic was later changed by #613 in order to fix another issue and the added `_hasLayout` may not fix anything eventually, as stated by [this comment](#432 (comment)). Fixes #1645. ## Changes - removed `_hasLayout` variable - added repros ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/91994767/226a32d7-728b-48dd-b21a-6a1e4195add2 ### After https://github.com/software-mansion/react-native-screens/assets/91994767/32febcf1-d159-4a9d-ae3a-373042732a6d ## Test code and steps to reproduce - added `Test1645.js` repro to test examples - added `Test432.tsx` repro to test examples ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]>
This PR gets rid of undesired white flashes during `maybeAddToParentAndUpdateContainer`. The white flash was present on paper architecture when `unmountOnBlur` option was set to true on parent bottomStackNavigator (see repro). The affected logic was previously introduced or changed by following PRs: - #600 - #613 - #643 The removed `_hasLayout` was initially added by #600 in order to resolve an issue: #432. However the logic was later changed by #613 in order to fix another issue and the added `_hasLayout` may not fix anything eventually, as stated by [this comment](#432 (comment)). Fixes #1645. - removed `_hasLayout` variable - added repros https://github.com/software-mansion/react-native-screens/assets/91994767/226a32d7-728b-48dd-b21a-6a1e4195add2 https://github.com/software-mansion/react-native-screens/assets/91994767/32febcf1-d159-4a9d-ae3a-373042732a6d - added `Test1645.js` repro to test examples - added `Test432.tsx` repro to test examples - [x] Included code example that can be used to test this change - [x] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]>
@elliottkember Thanks for the message. Having a working example from you would be ideal. |
One of the cases I can see is using useEffect(() => {
navigation.setOptions({
headerTitleAlign: 'center',
title: x ? '123123' : '1',
headerRight: x
? () => <HeaderRight />
: undefined,
})
}, [navigation, x]) When x changes from false to true, the If |
I found out that the project that @elliottkember and I work on has a default In fact the empty view wasn't the problem per se, it's the fact that the View expands while, at the same time, the title changes (or back button disappearing). In our case it was going from 0x0 to 20x20, but if you go from 20x20 to 30x20, the same issue happens useTimeout(() => setX(true), 2000)
useEffect(() => {
navigation.setOptions({
headerTitleAlign: 'center',
headerBackVisible: !x,
title: x ? '123123' : '1',
headerRight: x
? () => <View style={{backgroundColor:'green', width: 20, height: 20}} />
: () => <View style={{backgroundColor:'green', width: 1, height: 1}} />,
})
}, [navigation, x]) |
@thomasttvo Thanks for the repro! I can confirm it's reproducible on both paper and fabric arch. |
Setting the headerTitle in InteractionManager worked for me. useLayoutEffect(() => { |
…-mansion#2188) ## Description This PR gets rid of undesired white flashes during `maybeAddToParentAndUpdateContainer`. The white flash was present on paper architecture when `unmountOnBlur` option was set to true on parent bottomStackNavigator (see repro). The affected logic was previously introduced or changed by following PRs: - software-mansion#600 - software-mansion#613 - software-mansion#643 The removed `_hasLayout` was initially added by software-mansion#600 in order to resolve an issue: software-mansion#432. However the logic was later changed by software-mansion#613 in order to fix another issue and the added `_hasLayout` may not fix anything eventually, as stated by [this comment](software-mansion#432 (comment)). Fixes software-mansion#1645. ## Changes - removed `_hasLayout` variable - added repros ## Screenshots / GIFs ### Before https://github.com/software-mansion/react-native-screens/assets/91994767/226a32d7-728b-48dd-b21a-6a1e4195add2 ### After https://github.com/software-mansion/react-native-screens/assets/91994767/32febcf1-d159-4a9d-ae3a-373042732a6d ## Test code and steps to reproduce - added `Test1645.js` repro to test examples - added `Test432.tsx` repro to test examples ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]>
## Description This PR fixes the incorrect position of the custom header items when updating more than one option at the same time. The proposed solution let us remove the previous fix for a similar problem: software-mansion#2248 which only fixed the issue on fabric. Fixes software-mansion#432, software-mansion#2231. ## Changes - forced re-layout of the navigation controller when subviews are updated - removed previous fix - updated `Test432` repro <!-- ## Screenshots / GIFs Here you can add screenshots / GIFs documenting your change. You can add before / after section if you're changing some behavior. ### Before ### After --> ## Test code and steps to reproduce - use `Test432` and `Test2231` to test this fix on both architectures. ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes
## Description This PR fixes the incorrect position of the custom header items when updating more than one option at the same time. The proposed solution let us remove the previous fix for a similar problem: #2248 which only fixed the issue on fabric. Fixes #432, #2231. ## Changes - forced re-layout of the navigation controller when subviews are updated - removed previous fix - updated `Test432` repro <!-- ## Screenshots / GIFs Here you can add screenshots / GIFs documenting your change. You can add before / after section if you're changing some behavior. ### Before ### After --> ## Test code and steps to reproduce - use `Test432` and `Test2231` to test this fix on both architectures. ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes (cherry picked from commit bc95fa4)
I was testing the
createNativeStackNavigation
and ended up having this random issue where the component rendered byheaderRight
is being positioned incorrectly sometimes. There's nothing special in my code, I am just rendering a<Button>
fromreact-native
.Here's the source code: https://github.com/lnmunhoz/react-native-experiments/blob/master/react-navigation-examples/examples/NativeNavigation.tsx.
Update
The issue also happens when the
headerLargeTitle
isfalse
.The text was updated successfully, but these errors were encountered: