Skip to content

[0.64] Add onFocus/onBlur/onKeyDown/onKeyUp to Pressable #968

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

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Jan 19, 2022

Cherry pink #962 into 0.64-stable

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

Closes #518

Pressable was missing the onFocus/onBlur callbacks, I guess we missed this when we first added those props to Touchable. Let's go explicitly add them. I based my code off of the React Native Windows fork of Pressable.

In the future, I would also like to add Space/Enter keyboarding defaults to Pressable like React Native Windows has, where onKey(Down|Up) of Space/Enter on a Pressable is equivalent to onPress(In|Out). However, that would need me to make significant changes to how keyboard events work on macOS, so I'll just be sure to expose them now and leave it for later.

Changelog

[macOS] [Fixed] - Pressable didn't expose onFocus/onBlur

Test Plan

Added tests to rn-tester which indeed show onFocus/onBlur are fired.

* Add onFocus/onBlur/onKeyDown/onKeyUp to Pressable

* yarn lint --fix

* add validKeysUp/Down
@Saadnajmi Saadnajmi requested a review from alloy as a code owner January 19, 2022 18:36
@Saadnajmi Saadnajmi changed the title Pressable 64 [0.64] Add onFocus/onBlur/onKeyDown/onKeyUp to Pressable Jan 19, 2022
@pull-bot
Copy link

Fails
🚫

❗ Base Branch - The base branch for this PR is something other than master. Are you sure you want to target something other than the master branch?

🚫

❔ This pull request needs a description.

Warnings
⚠️ 🔒 package.json - Changes were made to package.json. This will require a manual import by a Facebook employee.
Messages
📖

📋 Missing Changelog - Can you add a Changelog? To do so, add a "## Changelog" section to your PR description. A changelog entry has the following format: [CATEGORY] [TYPE] - Message.

CATEGORY may be:
  • General
  • macOS
  • iOS
  • Android
  • JavaScript
  • Internal (for changes that do not need to be called out in the release notes)

TYPE may be:

  • Added, for new features.
  • Changed, for changes in existing functionality.
  • Deprecated, for soon-to-be removed features.
  • Removed, for now removed features.
  • Fixed, for any bug fixes.
  • Security, in case of vulnerabilities.

MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

📖 📋 Missing Test Plan - Can you add a Test Plan? To do so, add a "## Test Plan" section to your PR description. A Test Plan lets us know how these changes were tested.

Generated by 🚫 dangerJS against ff27979

@Saadnajmi Saadnajmi changed the base branch from main to 0.64-stable January 19, 2022 18:45
@Saadnajmi
Copy link
Collaborator Author

Closing till I get the CI in 0.64 in a better state

@Saadnajmi Saadnajmi closed this Jan 19, 2022
@Saadnajmi Saadnajmi reopened this Jan 21, 2022
@Saadnajmi Saadnajmi merged commit f67cfce into microsoft:0.64-stable Jan 21, 2022
@Saadnajmi Saadnajmi deleted the pressable-64 branch January 21, 2022 17:54
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.

3 participants