Skip to content

Commit

Permalink
disable click bubbling in pressable
Browse files Browse the repository at this point in the history
Differential Revision: D46081810

fbshipit-source-id: 27f3ff360eaa13cbeba0cc372ee95ede32a51408
  • Loading branch information
Alex Danoff authored and facebook-github-bot committed May 23, 2023
1 parent 25a529f commit 37fadad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/react-native/Libraries/Pressability/Pressability.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 37fadad

Please sign in to comment.