Skip to content

Commit c42ed3e

Browse files
authored
fix(iOS, Stack v4): crash on modal dismiss gesture with Pressable (#3133)
## Description Removes manual gesture cancel for modal dismiss on Fabric. Fixes software-mansion/react-native-screens-labs#360. The logic for cancelling gesture when modal will be dismissed has been added in #1485. On iOS 26 + Fabric, this code causes a crash (gesture update comes after resetting `_activeTouches` array, inconsistency is detected). The logic seems redundant now as the case described in the comment works without it on Fabric. I suspect this might've been patched in [this commit in `react-native`](facebook/react-native@379d9d4). On Paper, it is still necesssary. During testing, I noticed another bug - you can "catch" another pressable during animation. This however happens only on Paper. | Paper | Fabric | | --- | --- | | <video src="https://github.com/user-attachments/assets/a29d7a59-74b1-4ae8-8250-36bb1fafd362" /> | <video src="https://github.com/user-attachments/assets/b264caaa-91ff-433e-8618-6d946b6370ce" /> There are more places where we force the reset but I don't think that removing them all now is a good idea. We can go one-by-one, when any problems emerge. ## Changes - remove `presentationControllerWillDismiss` override on Fabric ## Screenshots / GIFs | before | after | | --- | --- | | <video src="https://github.com/user-attachments/assets/bb6ad158-04af-4ca2-a0c7-4cd2fae86de9" /> | <video src="https://github.com/user-attachments/assets/aefadd8e-6106-43b5-bf8f-dfd8a148c617" /> | ## Test code and steps to reproduce Run `Test3111` (that PR hasn't been merged at the moment) or `Test780` ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes
1 parent 0c68869 commit c42ed3e

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

ios/RNSScreen.mm

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,11 @@ - (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingFor
730730
#endif
731731
}
732732

733+
#if !RCT_NEW_ARCH_ENABLED
733734
- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController
734735
{
735-
// We need to call both "cancel" and "reset" here because RN's gesture recognizer
736-
// does not handle the scenario when it gets cancelled by other top
736+
// On Paper, we need to call both "cancel" and "reset" here because RN's gesture
737+
// recognizer does not handle the scenario when it gets cancelled by other top
737738
// level gesture recognizer. In this case by the modal dismiss gesture.
738739
// Because of that, at the moment when this method gets called the React's
739740
// gesture recognizer is already in FAILED state but cancel events never gets
@@ -742,14 +743,10 @@ - (void)presentationControllerWillDismiss:(UIPresentationController *)presentati
742743
// pulling down starting at some touchable item. Without "reset" the touchable
743744
// will never go back from highlighted state even when the modal start sliding
744745
// down.
745-
#ifdef RCT_NEW_ARCH_ENABLED
746-
[_touchHandler setEnabled:NO];
747-
[_touchHandler setEnabled:YES];
748-
#else
749746
[_touchHandler cancel];
750-
#endif
751747
[_touchHandler reset];
752748
}
749+
#endif // !RCT_NEW_ARCH_ENABLED
753750

754751
- (BOOL)presentationControllerShouldDismiss:(UIPresentationController *)presentationController
755752
{

0 commit comments

Comments
 (0)