Skip to content

feat(0.81): handle right clicks properly#2900

Open
Saadnajmi wants to merge 5 commits intomicrosoft:0.81-stablefrom
Saadnajmi:saadnajmi/onAuxClick-0.81
Open

feat(0.81): handle right clicks properly#2900
Saadnajmi wants to merge 5 commits intomicrosoft:0.81-stablefrom
Saadnajmi:saadnajmi/onAuxClick-0.81

Conversation

@Saadnajmi
Copy link
Copy Markdown
Collaborator

Summary

Backport of #2885 to 0.81-stable.

  • Add onAuxClick event for right-click and middle-click handling on macOS
  • Add onClick event for left single-click on plain Views
  • Fix onAuxClick prop registration in iterator-based setProp path
  • Override rightMouseDown: to prevent context menu modal from stealing rightMouseUp:
  • Add otherMouseDown:/otherMouseUp: for middle-click support
  • Prevent Pressable visual press feedback on non-primary mouse buttons
  • Align with upstream Implement onAuxClick facebook/react-native#56298 (shared cross-platform changes)

Test plan

  • Left-click on View → fires onClick with button=0
  • Double-click on View → fires onDoubleClick with button=0
  • Right-click on View → fires onAuxClick with button=2
  • Middle-click on View → fires onAuxClick with button=1
  • Right-click on Pressable → fires onAuxClick, does NOT trigger onPress or visual press state

🤖 Generated with Claude Code

Saadnajmi and others added 5 commits April 8, 2026 16:01
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>
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>
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>
…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 requested a review from a team as a code owner April 8, 2026 23:02
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: ae28e84

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

@Saadnajmi Saadnajmi changed the title feat: handle right clicks properly (backport to 0.81) feat(0.81): handle right clicks properly Apr 8, 2026
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.

1 participant