Skip to content

Commit

Permalink
fix: potentially fix iOS 16.0 navigation header title bug (#1579)
Browse files Browse the repository at this point in the history
## Description

Potentially fixes #1570 as suggested in
[comments](#1570 (comment)).

I tested it on iOS 16.0 simulator & device - worked for me. However when
I passed this solution to other team @software-mansion, it was reported
back to me that there is no change (buggy behaviour still occurs).

I'm gonna merge this PR, as it introduces only `line-swap` change, which
should not introduce any regression and potentially fixes the bug.

**NOTE**: this issue seems to be already fixed internally by Apple as
reported
[here](react-navigation/react-navigation#10840 (comment)).

## Changes

Just moved `navitem.title = ...` assignment below `navitem.titleView =
...` one.

## Test code and steps to reproduce

See #1570

## Checklist

- [ ] Ensured that CI passes
  • Loading branch information
kkafar committed Sep 23, 2022
1 parent 04b6c01 commit 07d8068
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ios/RNSFullWindowOverlay.mm
Expand Up @@ -4,11 +4,11 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/RCTSurfaceTouchHandler.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import <React/RCTFabricComponentsPlugins.h>
#else
#import <React/RCTTouchHandler.h>
#endif // RN_FABRIC_ENABLED
Expand Down
2 changes: 1 addition & 1 deletion ios/RNSScreen.mm
Expand Up @@ -6,13 +6,13 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/RCTRootComponentView.h>
#import <React/RCTSurfaceTouchHandler.h>
#import <react/renderer/components/rnscreens/EventEmitters.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import <rnscreens/RNSScreenComponentDescriptor.h>
#import <React/RCTFabricComponentsPlugins.h>
#import "RNSConvert.h"
#import "RNSScreenViewEvent.h"
#else
Expand Down
2 changes: 1 addition & 1 deletion ios/RNSScreenContainer.mm
Expand Up @@ -3,9 +3,9 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <React/RCTFabricComponentsPlugins.h>
#endif

@implementation RNScreensViewController
Expand Down
2 changes: 1 addition & 1 deletion ios/RNSScreenNavigationContainer.mm
Expand Up @@ -3,9 +3,9 @@
#import "RNSScreenContainer.h"

#ifdef RN_FABRIC_ENABLED
#import <React/RCTFabricComponentsPlugins.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <React/RCTFabricComponentsPlugins.h>
#endif

@implementation RNScreensContainerNavigationController
Expand Down
7 changes: 5 additions & 2 deletions ios/RNSScreenStackHeaderConfig.mm
@@ -1,11 +1,11 @@
#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/UIView+React.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/EventEmitters.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import <React/RCTFabricComponentsPlugins.h>
#else
#import <React/RCTBridge.h>
#import <React/RCTImageLoader.h>
Expand Down Expand Up @@ -459,7 +459,6 @@ + (void)updateViewController:(UIViewController *)vc
return;
}

navitem.title = config.title;
#if !TARGET_OS_TV
if (config.backTitle != nil || config.backTitleFontFamily || config.backTitleFontSize ||
config.disableBackButtonMenu) {
Expand Down Expand Up @@ -587,6 +586,10 @@ + (void)updateViewController:(UIViewController *)vc
}
}

// This assignment should be done after `navitem.titleView = ...` assignment (iOS 16.0 bug).
// See: https://github.com/software-mansion/react-native-screens/issues/1570 (comments)
navitem.title = config.title;

if (animated && vc.transitionCoordinator != nil &&
vc.transitionCoordinator.presentationStyle == UIModalPresentationNone && !wasHidden) {
// when there is an ongoing transition we may need to update navbar setting in animation block
Expand Down
2 changes: 1 addition & 1 deletion ios/RNSSearchBar.mm
Expand Up @@ -8,11 +8,11 @@

#ifdef RN_FABRIC_ENABLED
#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
#import <react/renderer/components/rnscreens/EventEmitters.h>
#import <react/renderer/components/rnscreens/Props.h>
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
#import <React/RCTFabricComponentsPlugins.h>
#import "RNSConvert.h"
#endif

Expand Down

1 comment on commit 07d8068

@Johan-dutoit
Copy link

Choose a reason for hiding this comment

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

This did not fix it for me unfortunately.

Please sign in to comment.