Skip to content

Preserve onClick/keyUp/keyDown event listener for Touchables #1348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

EyMaddis
Copy link

By default, React Native for Web handles some edge cases for Touchables which lead to unexpected behaviour.
Example:

<TouchableOpacity
 onClick={() => console.log('never called')}
 accessibilityRole="link"
>

vs

<TouchableOpacity
 onClick={() => console.log('called')}
 accessibilityRole="button"
>

For key events its even more extreme and might block propagation, but only if ENTER was used.

A little bit of context:
I develop a SmartTV App with React Native Web, in which I implemented spatial navigation (via arrow keys) in which I need to be able to globally handle ENTER events, this allows for a workaround.
What would already work help would be the removal of e.stopPropagation(). I was unsure whether this solves a specific problem, so I chose the opt-out method instead.

This makes my workaround from #1219 usable.

@EyMaddis EyMaddis mentioned this pull request May 16, 2019
@necolas
Copy link
Owner

necolas commented May 23, 2019

If you're listening to global events outside of React you can use the capture phase instead to work with events before they reach the bubble phase. No plans to add more events to the components

@necolas necolas closed this May 23, 2019
@EyMaddis
Copy link
Author

I am not sure I understand this correctly.
This contains two problems:

  1. onClick is blocked
  2. Propagation is blocked.

I understand your comment to only relate to 2. However, Issue 1 is more crucial as there is no way around it because the createElement will block the handler.

I could would be fine (under minor protest :) ) to leave out the propagation part, but blocking click for links is wrong in just wrong in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants