From a257e9f5f0cb871ead636e4dee0ce1271bb90df8 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Thu, 2 Nov 2023 07:39:30 -0700 Subject: [PATCH] Fixes Dev menu pop up multiple times when Tap command `D` continuously (#41234) Summary: Fixes Dev menu pop up multiple times when Tap command `D` continuously, demo like below: https://github.com/facebook/react-native/assets/5061845/b4c2b38d-ece6-4d4e-a823-23eaa7cad001 ## Changelog: [IOS] [FIXED] - Fixes Dev menu pop up multiple times when Tap command `D` continuously Pull Request resolved: https://github.com/facebook/react-native/pull/41234 Test Plan: Press `D` continuously, the menu pop up and dismiss correctly. Reviewed By: cipolleschi Differential Revision: D50925959 Pulled By: blakef fbshipit-source-id: 50fac9b4cea94c15a06ebc1b6092ebc9909cd9d2 --- packages/react-native/React/CoreModules/RCTDevMenu.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-native/React/CoreModules/RCTDevMenu.mm b/packages/react-native/React/CoreModules/RCTDevMenu.mm index 2154e3ebefc3e7..10b218a3f632e7 100644 --- a/packages/react-native/React/CoreModules/RCTDevMenu.mm +++ b/packages/react-native/React/CoreModules/RCTDevMenu.mm @@ -211,11 +211,15 @@ - (void)showOnShake - (void)toggle { + if (_actionSheet.isBeingPresented || _actionSheet.beingDismissed) { + return; + } if (_actionSheet) { [_actionSheet dismissViewControllerAnimated:YES - completion:^(void){ + completion:^(void) { + self->_actionSheet = nil; }]; - _actionSheet = nil; + } else { [self show]; }