diff --git a/packages/react-native-gesture-handler/apple/RNGestureHandler.mm b/packages/react-native-gesture-handler/apple/RNGestureHandler.mm index 6d746b6413..6f14b1ee89 100644 --- a/packages/react-native-gesture-handler/apple/RNGestureHandler.mm +++ b/packages/react-native-gesture-handler/apple/RNGestureHandler.mm @@ -116,7 +116,7 @@ - (void)resetConfig { self.enabled = YES; self.testID = nil; - self.manualActivation = NO; + _manualActivation = NO; _shouldCancelWhenOutside = NO; _cancelsJSResponder = YES; _hitSlop = RNGHHitSlopEmpty; @@ -132,6 +132,7 @@ - (void)setConfig:(NSDictionary *)config { [self resetConfig]; [self updateConfig:config]; + [self syncManualActivationRecognizer]; } - (void)updateConfig:(NSDictionary *)config @@ -665,14 +666,24 @@ - (void)stopActivationBlocker - (void)setManualActivation:(BOOL)manualActivation { _manualActivation = manualActivation; + [self syncManualActivationRecognizer]; +} + +- (void)syncManualActivationRecognizer +{ + BOOL hasRecognizer = _manualActivationRecognizer != nil; - if (manualActivation) { + if (hasRecognizer == _manualActivation) { + return; + } + + if (_manualActivation) { _manualActivationRecognizer = [[RNManualActivationRecognizer alloc] initWithGestureHandler:self]; if (_recognizer.view != nil) { [_recognizer.view addGestureRecognizer:_manualActivationRecognizer]; } - } else if (_manualActivationRecognizer != nil) { + } else { [_manualActivationRecognizer.view removeGestureRecognizer:_manualActivationRecognizer]; _manualActivationRecognizer = nil; }