Add onAuxClick event for right-click handling#2885
Add onAuxClick event for right-click handling#2885Saadnajmi wants to merge 2 commits intomicrosoft:mainfrom
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>
ArshVermaGit
left a comment
There was a problem hiding this comment.
Great work on bringing onAuxClick parity with upstream React Native — this is a thoughtful and well-scoped implementation. I really appreciate how carefully the macOS-specific path was handled, especially routing through RCTViewComponentView.mm since RCTSurfacePointerHandler isn’t used on macOS. Adding the button field aligned with the W3C spec makes the event feel consistent and future-proof, and the Pressability filtering ensures existing press behavior stays intuitive (right-click no longer triggering onPress is exactly what developers would expect). The test plan is solid and clearly validates both regression safety and correctness of the new event. Overall, this feels like a clean, pragmatic change that integrates smoothly with the existing event system while improving platform consistency. Nicely done! 👏
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
onAuxClickfires on right-click on a<View>in RNTesteronPressdoes not fire on right-click on a<Pressable>onDoubleClickand other existing mouse events still workevent.nativeEvent.buttonreports correct values (0 for left, 2 for right)🤖 Generated with Claude Code