Skip to content

Commit 37fadad

Browse files
Alex Danofffacebook-github-bot
Alex Danoff
authored andcommitted
disable click bubbling in pressable
Differential Revision: D46081810 fbshipit-source-id: 27f3ff360eaa13cbeba0cc372ee95ede32a51408
1 parent 25a529f commit 37fadad

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/react-native/Libraries/Pressability/Pressability.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,13 @@ export default class Pressability {
553553
return;
554554
}
555555

556+
// for non-pointer click events (e.g. accessibility clicks), we should only dispatch when we're the "real" target
557+
// in particular, we shouldn't respond to clicks from nested pressables
558+
if (event?.currentTarget !== event?.target) {
559+
event?.stopPropagation();
560+
return;
561+
}
562+
556563
const {onPress, disabled} = this._config;
557564
if (onPress != null && disabled !== true) {
558565
onPress(event);

0 commit comments

Comments
 (0)