Skip to content

Conversation

@NickGerleman
Copy link
Contributor

@NickGerleman NickGerleman commented May 17, 2020

Fixes #4598

This change reenables touchables to be activated by keyboard/Gamepad. The implementation is mostly stolen from the previous that was used for Touchable. This doesn't participate in the input state machine, as its coupled to touch input. This means we don't get things like long-press detection (whether we want that is questionable), but we do still get feedback for key-in and key-out.

We should do something better when we upstream keyboard behavior to do proper integration into the Pressability state machine, but this is invasive enough that we shouldn't fork this.

Validated Spacebar and enter functionality with various touchables.

Microsoft Reviewers: Open in CodeFlow

Fixes microsoft#4598

This change reenables touchables to be activated by keyboard/Gamepad. The implementation is mostly stolen from the previous that was used for Touchable. Like before, this doesn't participate in the input state machine, as its coupled to touch input. This means we don't get things like long-press detection, but we do still get feedback for key-in and key-out.

We should do something better when we upstream keyboard behavior to do proper integration into the Pressability state machine, but this is invasive enough that we shouldn't fork this.

Validated Spacebar and enter functionality with various touchables.
@NickGerleman NickGerleman requested a review from a team as a code owner May 17, 2020 17:28
Comment on lines +525 to +529
const mouseEventHandlers =
Platform.OS === 'ios' || Platform.OS === 'android'
? null
: {
onMouseEnter: (event: MouseEvent): void => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious to know what's going on here. We saw MouseEvent show up in 0.62, but IIRC didn't get an understanding of why. Wondering if they're being proactive for react-native-web?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think FB uses pressablilty on web too. These events are not hooked up to anything in RN, and may be removed in the future. (It sounds like it was a bit of a mistake they ever got into RN in their current form)

Comment on lines 577 to 578
// $FlowFixMe: PressEvents don't mesh with keyboarding APIs. Keep legacy behavior of pasing KeyEvents instead
onPressOut && onPressOut(event);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is terrible of course 😉

All options involve some level of passing garbage unless we make upstream API changes unfortunately. This method of passing garbage is simple and the same as before though.

@NickGerleman NickGerleman added the AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity) label May 19, 2020
@ghost
Copy link

ghost commented May 19, 2020

Hello @NickGerleman!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 1e55356 into microsoft:master May 19, 2020
NickGerleman added a commit to NickGerleman/react-native-windows that referenced this pull request May 19, 2020
…4930)

* Implement Keybpoarding/Gamepad Activation for Pressability

Fixes microsoft#4598

This change reenables touchables to be activated by keyboard/Gamepad. The implementation is mostly stolen from the previous that was used for Touchable. Like before, this doesn't participate in the input state machine, as its coupled to touch input. This means we don't get things like long-press detection, but we do still get feedback for key-in and key-out.

We should do something better when we upstream keyboard behavior to do proper integration into the Pressability state machine, but this is invasive enough that we shouldn't fork this.

Validated Spacebar and enter functionality with various touchables.

* Change files

* Flow fixes

* Fix typo
NickGerleman added a commit that referenced this pull request May 19, 2020
* Implement Keybpoarding/Gamepad Activation for Pressability

Fixes #4598

This change reenables touchables to be activated by keyboard/Gamepad. The implementation is mostly stolen from the previous that was used for Touchable. Like before, this doesn't participate in the input state machine, as its coupled to touch input. This means we don't get things like long-press detection, but we do still get feedback for key-in and key-out.

We should do something better when we upstream keyboard behavior to do proper integration into the Pressability state machine, but this is invasive enough that we shouldn't fork this.

Validated Spacebar and enter functionality with various touchables.

* Change files

* Flow fixes

* Fix typo
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AutoMerge Causes a PR to be automatically merged once all requirements are passed (label drives bot activity)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reimplement Keyboarding Behavior on top of Pressability

2 participants