Skip to content

Commit

Permalink
fix(iOS): update HeaderConfig view controller after unmounting subvie…
Browse files Browse the repository at this point in the history
…ws (software-mansion#2230)

## Description

When using a header left view and then removing it the default back
button doesn't reappear on new arch. This is because we do not call
`updateViewControllerIfNeeded` when removing views.

## Changes

Call `updateViewControllerIfNeeded` in `unmountChildComponentView`.

## Test code and steps to reproduce

In the FabricExample HeaderOptions example:

- Open Header item setting
- Choose left
- Choose right
- See the back button is gone.

<img width="368" alt="image"
src="https://github.com/software-mansion/react-native-screens/assets/2677334/d5bfea6e-d0f4-4527-9f90-99f19c6045e5">

<img width="381" alt="image"
src="https://github.com/software-mansion/react-native-screens/assets/2677334/3338435c-c48f-4858-bd8a-97103a396fcd">

<img width="368" alt="image"
src="https://github.com/software-mansion/react-native-screens/assets/2677334/143349b0-6f66-460b-9920-14e4a50f16bc">

When toggling state the default back button doesn't reappear.

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
  • Loading branch information
janicduplessis authored and ja1ns committed Oct 9, 2024
1 parent bee5cae commit 0ad27d8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
[self replaceNavigationBarViewsWithSnapshotOfSubview:(RNSScreenStackHeaderSubview *)childComponentView];
[_reactSubviews removeObject:(RNSScreenStackHeaderSubview *)childComponentView];
[childComponentView removeFromSuperview];
[self updateViewControllerIfNeeded];
}

- (void)replaceNavigationBarViewsWithSnapshotOfSubview:(RNSScreenStackHeaderSubview *)childComponentView
Expand Down

0 comments on commit 0ad27d8

Please sign in to comment.