Skip to content
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

Support onPress/onLongPress in usePressableState #1061

Merged
merged 3 commits into from
Oct 12, 2021

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Oct 12, 2021

Platforms Impacted

  • iOS
  • macOS
  • win32 (Office)
  • windows
  • android

Description of changes

Related: #1035

With #863 , we introduced the hook "usePressableState" as a first step to get us off our local version of Pressable, and to use the stock React Native component instead. I'm working on completing that work for my FHL project (a week long hackathon at Microsoft). I'm working through all the issues of using the new hook vs the old one (useAsPressable). To start with, I'll start with a simple and easy fix:

To start with, I noticed that we don't pass "onPress/onLongPress" as callbacks into usePressHelper, which is used by usePressState. Thus, any of the components I tried to switch to use this new hook didn't actually execute their onPress props. We should just fix this by extending usePressHelper to support onPress/onLongPress on top of onPressIn/onPressOut.

Other things I did:

  • Removed the markdown file interactive-hooks.api.md. This is a leftover file from Remove api extractor #854 where we forgot to remove this file.
  • Reordered the objects spat out from both hooks to follow the same "canonical" (read: arbitrary) order of "hover / focus / press" so that it's easier to compare the states from each hook while debugging.
  • Removes the platform check for the hover handlers from usePressableState. Stock Pressable handles this internally.

Verification

Locally switched components like Button and Checkbox to use the new hook and verified that their onPress callback was called.

Pull request checklist

This PR has considered (when applicable):

  • Automated Tests
  • Documentation and examples
  • Keyboard Accessibility
  • Voiceover
  • Internationalization and Right-to-left Layouts

@Saadnajmi Saadnajmi requested a review from harrieshin October 12, 2021 19:11
@Saadnajmi Saadnajmi merged commit 8533954 into microsoft:master Oct 12, 2021
@Saadnajmi Saadnajmi deleted the pressable-fix branch October 12, 2021 19:28
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