Skip to content

Add onAuxClick event for right-click handling#2885

Draft
Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
Saadnajmi:saadnajmi/onAuxClick
Draft

Add onAuxClick event for right-click handling#2885
Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
Saadnajmi:saadnajmi/onAuxClick

Conversation

@Saadnajmi
Copy link
Copy Markdown
Collaborator

@Saadnajmi Saadnajmi commented Apr 2, 2026

Summary

  • Implements onAuxClick event, matching the upstream implementation in facebook/react-native#56298
  • Shared changes (from upstream): Adds onAuxClick/onAuxClickCapture to TouchEventEmitter, ViewEvents (primitives.h), propsConversions.h, BaseViewConfig.ios.js (bubbling event), RCTSurfacePointerHandler.mm (iOS dispatch), and PointerEventProps types
  • macOS-specific changes: Since macOS doesn't use RCTSurfacePointerHandler.mm (guarded with #if !TARGET_OS_OSX), adds native wiring through RCTViewComponentView.mm (rightMouseUp:HostPlatformViewEventEmitter::onAuxClick)
  • Adds a button field to the macOS MouseEvent struct (W3C spec: 0=left, 1=middle, 2=right)
  • Filters non-primary button clicks from triggering onPress in Pressability, so right-clicking a Pressable no longer fires its press handler

Test plan

  • Verify onAuxClick fires on right-click on a <View> in RNTester
  • Verify onPress does not fire on right-click on a <Pressable>
  • Verify onDoubleClick and other existing mouse events still work
  • Verify event.nativeEvent.button reports correct values (0 for left, 2 for right)

🤖 Generated with Claude Code

Implements onAuxClick following the same pattern as onDoubleClick, wired
end-to-end from native rightMouseUp: through C++ event emitters to JS.
Also adds a `button` field to MouseEvent and filters non-primary button
clicks from triggering onPress in Pressability.

Inspired by microsoft/react-native-windows#15920.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

⚠️ No Changeset found

Latest commit: a750192

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Port the shared changes from facebook#56298:
- Add onAuxClick/onAuxClickCapture to TouchEventEmitter (shared C++)
- Add AuxClick/AuxClickCapture to ViewEvents in primitives.h
- Add prop conversions in propsConversions.h
- Register topAuxClick as a bubbling event in BaseViewConfig.ios.js
- Add dispatch logic in RCTSurfacePointerHandler.mm (iOS path)
- Type onAuxClick as PointerEvent in PointerEventProps (Flow + TS)

Remove redundant macOS-specific JS registrations since macOS now
inherits the bubbling event from the iOS base config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Consider using caret range for react-native peer dependency @react-native-community/cli shows outdated macOS setup link for React Native macOS

1 participant