Skip to content

feat: handle right clicks properly#2885

Open
Saadnajmi wants to merge 5 commits intomicrosoft:mainfrom
Saadnajmi:saadnajmi/onAuxClick
Open

feat: handle right clicks properly#2885
Saadnajmi wants to merge 5 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

Event log matches my button presses

Screenshot 2026-04-08 at 3 38 45 PM

🤖 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: 4b76671

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>
ArshVermaGit

This comment has been minimized.

Saadnajmi and others added 2 commits April 8, 2026 11:58
Match react-native-windows approach: add _isDefaultPressButton() helper
and use it in all three press paths (onClick, LONG_PRESS_DETECTED, and
RESPONDER_RELEASE). The button property is already forwarded from native
macOS touch events via BaseTouch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add MouseClickEventsExample to ViewExample.js with both a plain View
  and a Pressable target to verify onAuxClick fires and onPress does not
  on right-click
- Document onAuxClick in docsite view-events.md with event data spec
  and usage example
- Add button property to onDoubleClick event data docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi marked this pull request as ready for review April 8, 2026 23:00
@Saadnajmi Saadnajmi requested a review from a team as a code owner April 8, 2026 23:00
@Saadnajmi Saadnajmi changed the title Add onAuxClick event for right-click handling feat: handle right clicks properly Apr 8, 2026
…ght-click

- Add onClick event for left single-click on plain Views (macOS)
- Fix onAuxClick by adding missing VIEW_EVENT_CASE_MACOS entries in setProp
- Override rightMouseDown: to prevent context menu modal from consuming rightMouseUp:
- Add otherMouseDown:/otherMouseUp: for middle-click (button=1) via onAuxClick
- Add pointerType:"mouse" to mouse event payload for Pressability guard
- Add onAuxClick to Paper architecture (RCTView.h, RCTViewManager.m)
- Guard Pressability _activate against non-primary buttons to prevent
  visual pressed state on right-click/middle-click

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi force-pushed the saadnajmi/onAuxClick branch from d868993 to 4b76671 Compare April 8, 2026 23:02
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

2 participants