Skip to content

Conversation

@lawrencewin
Copy link
Contributor

@lawrencewin lawrencewin commented Jul 11, 2025

Platforms Impacted

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

Description of changes

React Native MacOS pressables handle a special case for ENTER / SPACE keys for the keyDown / keyDown event handlers: these keys should also be interpreted as presses, thus causing the event to be passed to the onPress handler. The code for this is found here: https://github.com/microsoft/react-native-macos/blob/48e607706bfcc25b4c28eba1aa352f409c02975e/packages/react-native/Libraries/Pressability/Pressability.js#L580-L617

For the MenuItem, we pass onInvoke, the handler for clicks and keypresses, into both press and keyDown / keyUp handlers. The code snippet above, then causes onClick to be called twice on the platform. We can fix this by simply marking the event as handled, so onClick is only called once.

Verification

Tested locally, video:

menu.item.working.mp4

Pull request checklist

This PR has considered (when applicable):

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

@lawrencewin lawrencewin requested a review from a team as a code owner July 11, 2025 21:41
@lawrencewin lawrencewin force-pushed the menuitem-duplicate-keydown-fix branch from d20108d to c658d7d Compare July 15, 2025 01:26
@lawrencewin lawrencewin merged commit 93700bb into microsoft:main Jul 17, 2025
11 checks passed
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