diff --git a/packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm b/packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm index 85f9ff8bb6..af27a5a3d0 100644 --- a/packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm +++ b/packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm @@ -360,6 +360,19 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & } [super updateProps:props oldProps:oldProps]; + +#if !TARGET_OS_TV && !TARGET_OS_OSX + // super's updateProps sets self.accessibilityIdentifier from testID via the + // standard Fabric mechanism. However, setAccessibilityProps already forwards + // testID to _buttonView.accessibilityIdentifier (the actual button element). + // Having the identifier on both views causes testing frameworks (e.g. Detox) + // to report multiple matches for the same testID. Clear it from the wrapper so + // only _buttonView carries the identifier. + if (!newProps.testId.empty()) { + self.accessibilityIdentifier = nil; + } +#endif + if (shouldApplyStartAnimationState) { [_buttonView applyStartAnimationState]; }