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

Header right elements disappear on rotate #528

Closed
JackMoseley2001 opened this issue May 29, 2020 · 11 comments · Fixed by #902
Closed

Header right elements disappear on rotate #528

JackMoseley2001 opened this issue May 29, 2020 · 11 comments · Fixed by #902
Labels
Area: Native Stack Bug Something isn't working Platform: iOS This issue is specific to iOS

Comments

@JackMoseley2001
Copy link

Hello,

I've noticed that any elements placed inside header right (both using navigation.setOptions and view the Stack.Screen options) show when the stack is initially shown, but then if the device is rotated they disappear until the view is next reloaded.

This is only happening when the stack is created using createNativeStackNavigator and not when using React Navigation's createStackNavigator.

Anyone else encountering this? Any help would be appreciated.

@leoz
Copy link

leoz commented May 29, 2020

Same here.

@WoLewicki WoLewicki added Bug Something isn't working Platform: iOS This issue is specific to iOS Area: Native Stack labels Jun 1, 2020
@WoLewicki
Copy link
Member

The bug is most probably the same as #432, but we can keep this one open too. And it only happens on iOS right?

@JackMoseley2001
Copy link
Author

The bug is most probably the same as #432, but we can keep this one open too. And it only happens on iOS right?

Thank you. I have only been able to test it on iOS so far, will have the chance to test it on an Android simulator today and will update once I have done so.

I saw on the post linked there was mention to expo - if linked, it’s worth noting that this issue I’m encountering is occurring in a bare react native project.

@WoLewicki
Copy link
Member

You can try the solution mentioned in #322 and see if it fixes the issue in your case.

@JackMoseley2001
Copy link
Author

Thanks, I will attempt this workaround also

@JackMoseley2001
Copy link
Author

You can try the solution mentioned in #322 and see if it fixes the issue in your case.

I've attempted this solution, it works some of the time, but to get somewhat reliable results I needed to increase the delay time, resulting in the buttons appearing after some time. I did continue to find that the button would disappear though - going from portrait to landscape worked, but then it failed to show when going from landscape to portrait again

@WoLewicki
Copy link
Member

I will close it to keep the discussion about the issue in one place. Please see #432 for more information.

@WoLewicki
Copy link
Member

Can you check if #644 fixes your issue and do not introduce any new bugs?

@WoLewicki WoLewicki linked a pull request Sep 18, 2020 that will close this issue
@JackMoseley2001
Copy link
Author

Thank you for taking time to have a look at this problem.

I have installed and tested the pull request regarding this, but am still experiencing that the icon will disappear on rotate. I have tried it by setting the right icon within the screen itself using props, and within the stack navigator screen.

I have since reporting this issue moved away from using React Native for the meantime and therefore hope that anyone within issue #432 may be able to help more.

@zibs
Copy link

zibs commented Oct 15, 2020

Copy pasting my comment from #432 by request.

Hey @WoLewicki thanks for the follow up. Can you check out this updated gif and see if you have any insights? I've integrated the workaround you proposed in #644 into my repo, and it seems to partly fix one issue, but the not issue I'm hunting down in particular:

You can see in this gif that it works fine now while rotating on screen 1, but you if go to screen 2, rotate there, and then come back to screen1 (happens at the end of the gif), the header button is gone again.

Screen Recording 2020-10-14 at 8 38 46 AM

Like I said, the repo is updated if you want to run it, and it's applying your patch when built.

Here's a MVCE (minimally viable complete example) of the issue:
Repo

zibs added a commit to zibs/react-native-screens that referenced this issue Oct 18, 2020
Adds ensureHeaderButtonsVisible method in RNScreens.m
References issues  software-mansion#432 and software-mansion#528.
abram added a commit to developandfix/react-native-screens that referenced this issue Apr 30, 2021
)

This addresses bugs like software-mansion#528 where header content gets incorrectly
positioned on initial load or after rotation. I was experiencing
these issues in my current app, and when I looked at the XCode
view debugger I could see that RNSScreenStackHeaderConfig.subviews
were having their .frame.origin.x property set to a non-zero
value that moved them out of place.

I'm fairly new to React Native and very new to this codebase, so
I haven't totally got to the bottom of what's happening here. My
guess/theory is that RN layout code is setting the position of
these views as if they're part of of the regular view hierarchy,
even though they're meant to be managed by a UINavigationBar. Rather
than trying to fix this at a deeper level and risk introducing side
effects, I've added this small workaround.
@WoLewicki
Copy link
Member

Can you check if #902 fixes all of the scenarios? If so, I think we will merge it or something very similar as the solution to the problem 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Native Stack Bug Something isn't working Platform: iOS This issue is specific to iOS
Projects
None yet
4 participants