feat: handle right clicks properly#2885
Open
Saadnajmi wants to merge 5 commits intomicrosoft:mainfrom
Open
Conversation
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>
This was
linked to
issues
Apr 4, 2026
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>
d868993 to
4b76671
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
onAuxClickevent, matching the upstream implementation in facebook/react-native#56298onAuxClick/onAuxClickCapturetoTouchEventEmitter,ViewEvents(primitives.h),propsConversions.h,BaseViewConfig.ios.js(bubbling event),RCTSurfacePointerHandler.mm(iOS dispatch), andPointerEventPropstypesRCTSurfacePointerHandler.mm(guarded with#if !TARGET_OS_OSX), adds native wiring throughRCTViewComponentView.mm(rightMouseUp:→HostPlatformViewEventEmitter::onAuxClick)buttonfield to the macOSMouseEventstruct (W3C spec: 0=left, 1=middle, 2=right)onPressinPressability, so right-clicking aPressableno longer fires its press handlerTest plan
Event log matches my button presses
🤖 Generated with Claude Code