-
-
Notifications
You must be signed in to change notification settings - Fork 591
feat(iOS, Stack): update back button configuration logic to handle iOS 26 and fix other problems #3303
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
base: main
Are you sure you want to change the base?
Conversation
e039a98 to
89f9390
Compare
guides/GUIDE_FOR_LIBRARY_AUTHORS.md
Outdated
|
|
||
| ### `backButtonUseModernImplementation` (iOS only) | ||
|
|
||
| Used for backward compatibility only. Setting this prop to `false` is recommended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not recommended in every case - imo we should rather recommend migrating to the new implementation; we should be more specific about the versioning here. If we don't know which version of React Navigation it will be in, we should at least create a ticket to revisit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot to change values and description here. Previously the prop was useLegacyImplementation. Now it should be correct.
I created a ticket to add info about versions in the future: https://github.com/software-mansion/react-native-screens-labs/issues/513.
|
I thought about using |
Description
Fixes back button configuration logic to handle following problems:
react-native-screens' behavior was different,minimaldisplay mode withdisableBackButtonMenu: truedid not work correctly (back button menu remained enabled) .The only case that won't be supported after this PR (but it also hasn't been supported prior to this PR) is
genericdisplay mode on iOS versions prior to 26 whenbackTitleFontFamily,backTitleFontSizeordisableBackButtonMenuis set. I decided that the appropriate approach is to fallback todefaultdisplay mode behavior.Reasoning
Prior to this PR, there were many attempts to fix the back button configuration logic (e.g. #2800, #2860, #2867) but after native behavior change in iOS 26, I decided to have a look at this problem once again.
Here are the most important observations:
backButtonDisplayModeproperty is ignored (what, to be fair, makes sense).backButtonTitleproperty (or use custom back button).genericback button text in custom back button (there is no API to get the localized string).Keeping those observations in mind, this is the configuration flow proposed in this PR:
Here is the comparison between prior and after this PR based on
Test2809:Compatibility with previous versions
In order to maintain compatibility with previous
react-native-screensandreact-navigationversions, I addedbackButtonUseModernImplementationprop.New
react-navigation, newreact-native-screensIn new
react-navigationrelease, we need to setbackButtonUseModernImplementationtotrueand always passbackButtonDisplayMode. Here is the patch toreact-navigation:New version of
react-native-screenswill use new implementation only if it receivesbackButtonUseModernImplementation=true. By default, the prop isfalse.Old
react-navigation, newreact-native-screensNo
backButtonUseModernImplementation->backButtonUseModernImplementation=false(default value) ->react-native-screensuses legacy implementation, no changes to the back button logic.New
react-navigation, oldreact-native-screensreact-native-screensuses old implementation. PassingbackButtonDisplayModealways directly, without the logic fromreact-navigationto passundefinedin some cases will not change anything -undefinedwas passed only when back button required customization. In such cases,backButtonDisplayModeis ignored by the system already.Changes
backTitleVisiblebackButtonUseNewImplementationto switch between legacy and modern implementationsTest2809Test code and steps to reproduce
Run
Test2809. Please note the changes required toreact-navigationto see new behavior.Checklist