feat(iOS, Stack): update back button configuration logic to handle iOS 26 and fix other problems#3303
feat(iOS, Stack): update back button configuration logic to handle iOS 26 and fix other problems#3303
Conversation
e039a98 to
89f9390
Compare
|
|
||
| ### `backButtonUseModernImplementation` (iOS only) | ||
|
|
||
| Used for backward compatibility only. Setting this prop to `false` is recommended. |
There was a problem hiding this comment.
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.
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 |
8009f8c to
2e4f3b6
Compare
|
Just a status update from my end: this is a complicated PR that requires a lot of testing and at the same time is not of high priority, therefore I can not really find time to review it properly. I've added it to next iteration with higher priority. |
## Description Closes https://github.com/software-mansion/react-native-screens-labs/issues/540 Broad changes after iOS 26.2 and some by-the-way fixes or improvements. Not fixed tests: iOS tests for example Test2809 should be aligned later with an output of PR #3303. iOS tests for examples Test645 and Test649 are affected by issue [#566](https://github.com/software-mansion/react-native-screens-labs/issues/566) ## Changes Detox e2e tests. Increased test isolation. Bar back button technical selector depends now on ios version. Some android emulators my get a pop-up about using stylus which interrupts the test flow – it is disabled in the global config now. ## Checklist - [x] Included code example that can be used to test this change - [x] Updated TS types - [x] Updated documentation: <!-- For adding new props to native-stack --> - [x] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes --------- Co-authored-by: Krzysztof Wojnar <[email protected]> Co-authored-by: Krzysztof Ligarski <[email protected]> Co-authored-by: Konrad Michalik <[email protected]>
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.Closes https://github.com/software-mansion/react-native-screens-labs/issues/578.
Closes #3551.
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