11import React , { useEffect , useRef } from 'react' ;
22import type { GestureResponderEvent } from 'react-native' ;
33import PressableWithFeedback from '@components/Pressable/PressableWithFeedback' ;
4+ import usePressResponderProps from '@components/Pressable/PressResponder/usePressResponderProps' ;
45import useStyleUtils from '@hooks/useStyleUtils' ;
56import useThemeStyles from '@hooks/useThemeStyles' ;
67import { canUseTouchScreen , hasHoverSupport } from '@libs/DeviceCapabilities' ;
@@ -16,7 +17,7 @@ function PressableWithSecondaryInteraction({
1617 withoutFocusOnSecondaryInteraction = false ,
1718 needsOffscreenAlphaCompositing = false ,
1819 preventDefaultContextMenu = true ,
19- onSecondaryInteraction,
20+ onSecondaryInteraction : rawOnSecondaryInteraction ,
2021 activeOpacity = 1 ,
2122 opacityAnimationDuration,
2223 ref,
@@ -25,6 +26,14 @@ function PressableWithSecondaryInteraction({
2526 const styles = useThemeStyles ( ) ;
2627 const StyleUtils = useStyleUtils ( ) ;
2728 const pressableRef = useRef < HTMLDivElement | null > ( null ) ;
29+ // Forward the a11y slot so it reaches the underlying pressable even when the descendant isn't `<PressableWithFeedback>`.
30+ const { onSecondaryInteraction, accessibilityState, accessibilityHasPopup, nativeID, accessibilityControls} = usePressResponderProps ( {
31+ onSecondaryInteraction : rawOnSecondaryInteraction ,
32+ accessibilityState : rest . accessibilityState ,
33+ accessibilityHasPopup : rest . accessibilityHasPopup ,
34+ nativeID : rest . nativeID ,
35+ accessibilityControls : rest . accessibilityControls ,
36+ } ) ;
2837
2938 const executeSecondaryInteraction = ( event : GestureResponderEvent ) => {
3039 if ( hasHoverSupport ( ) && ! enableLongPressWithHover ) {
@@ -92,9 +101,11 @@ function PressableWithSecondaryInteraction({
92101 // On Web, Text does not support LongPress events thus manage inline mode with styling instead of using Text.
93102 return (
94103 < PressableWithFeedback
95- // ESLint is disabled here to propagate all the props, enhancing PressableWithSecondaryInteraction's versatility across different use cases.
96-
97104 { ...rest }
105+ accessibilityState = { accessibilityState }
106+ accessibilityHasPopup = { accessibilityHasPopup }
107+ nativeID = { nativeID }
108+ accessibilityControls = { accessibilityControls }
98109 wrapperStyle = { [ StyleUtils . combineStyles ( canUseTouchScreen ( ) ? [ styles . userSelectNone , styles . noSelect ] : [ ] , inlineStyle ) , wrapperStyle ] }
99110 onLongPress = { onSecondaryInteraction ? executeSecondaryInteraction : undefined }
100111 pressDimmingValue = { activeOpacity }
0 commit comments