From 37fadad81e29688acfaf438e34326f321e8e567e Mon Sep 17 00:00:00 2001 From: Alex Danoff Date: Tue, 23 May 2023 11:11:59 -0700 Subject: [PATCH] disable click bubbling in pressable Differential Revision: D46081810 fbshipit-source-id: 27f3ff360eaa13cbeba0cc372ee95ede32a51408 --- .../react-native/Libraries/Pressability/Pressability.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-native/Libraries/Pressability/Pressability.js b/packages/react-native/Libraries/Pressability/Pressability.js index 39c0807f3437f6..803572cc677a5b 100644 --- a/packages/react-native/Libraries/Pressability/Pressability.js +++ b/packages/react-native/Libraries/Pressability/Pressability.js @@ -553,6 +553,13 @@ export default class Pressability { return; } + // for non-pointer click events (e.g. accessibility clicks), we should only dispatch when we're the "real" target + // in particular, we shouldn't respond to clicks from nested pressables + if (event?.currentTarget !== event?.target) { + event?.stopPropagation(); + return; + } + const {onPress, disabled} = this._config; if (onPress != null && disabled !== true) { onPress(event);