@@ -8,6 +8,7 @@ import useOnyx from '@hooks/useOnyx';
88import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
99import useTheme from '@hooks/useTheme' ;
1010import useThemeStyles from '@hooks/useThemeStyles' ;
11+ import { canUseTouchScreen } from '@libs/DeviceCapabilities' ;
1112import useIsHomeRouteActive from '@navigation/helpers/useIsHomeRouteActive' ;
1213import variables from '@styles/variables' ;
1314import CONST from '@src/CONST' ;
@@ -27,6 +28,9 @@ type FloatingActionButtonProps = {
2728 /* Callback to fire on request to toggle the FloatingActionButton */
2829 onPress : ( event : GestureResponderEvent | KeyboardEvent | undefined ) => void ;
2930
31+ /* Callback to fire on long press of the FloatingActionButton */
32+ onLongPress ?: ( event : GestureResponderEvent | KeyboardEvent | undefined ) => void ;
33+
3034 /* Current state (active or not active) of the component */
3135 isActive : boolean ;
3236
@@ -40,7 +44,7 @@ type FloatingActionButtonProps = {
4044 isTooltipAllowed : boolean ;
4145} ;
4246
43- function FloatingActionButton ( { onPress, isActive, accessibilityLabel, role, isTooltipAllowed} : FloatingActionButtonProps , ref : ForwardedRef < HTMLDivElement | View | Text > ) {
47+ function FloatingActionButton ( { onPress, onLongPress , isActive, accessibilityLabel, role, isTooltipAllowed} : FloatingActionButtonProps , ref : ForwardedRef < HTMLDivElement | View | Text > ) {
4448 const { success, buttonDefaultBG, textLight} = useTheme ( ) ;
4549 const styles = useThemeStyles ( ) ;
4650 const borderRadius = styles . floatingActionButton . borderRadius ;
@@ -88,6 +92,19 @@ function FloatingActionButton({onPress, isActive, accessibilityLabel, role, isTo
8892 onPress ( event ) ;
8993 } ;
9094
95+ const longPressFabAction = ( event : GestureResponderEvent | KeyboardEvent | undefined ) => {
96+ // Only execute on narrow layout - prevent event from firing on wide screens
97+ if ( ! shouldUseNarrowLayout ) {
98+ return ;
99+ }
100+
101+ hideProductTrainingTooltip ( ) ;
102+
103+ // Drop focus to avoid blue focus ring.
104+ fabPressable . current ?. blur ( ) ;
105+ onLongPress ?.( event ) ;
106+ } ;
107+
91108 return (
92109 < EducationalTooltip
93110 shouldRender = { shouldShowProductTrainingTooltip }
@@ -108,10 +125,16 @@ function FloatingActionButton({onPress, isActive, accessibilityLabel, role, isTo
108125 buttonRef . current = el ?? null ;
109126 }
110127 } }
111- style = { [ styles . h100 , styles . navigationTabBarItem ] }
128+ style = { [
129+ styles . h100 ,
130+ styles . navigationTabBarItem ,
131+
132+ // Prevent text selection on touch devices (e.g. on long press)
133+ canUseTouchScreen ( ) && styles . userSelectNone ,
134+ ] }
112135 accessibilityLabel = { accessibilityLabel }
113136 onPress = { toggleFabAction }
114- onLongPress = { ( ) => { } }
137+ onLongPress = { longPressFabAction }
115138 role = { role }
116139 shouldUseHapticsOnLongPress = { false }
117140 testID = "floating-action-button"
0 commit comments