@@ -5,6 +5,7 @@ import * as Expensicons from '@components/Icon/Expensicons';
5
5
import OfflineWithFeedback from '@components/OfflineWithFeedback' ;
6
6
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback' ;
7
7
import useHover from '@hooks/useHover' ;
8
+ import { useMouseContext } from '@hooks/useMouseContext' ;
8
9
import useSyncFocus from '@hooks/useSyncFocus' ;
9
10
import useTheme from '@hooks/useTheme' ;
10
11
import useThemeStyles from '@hooks/useThemeStyles' ;
@@ -36,11 +37,16 @@ function BaseListItem<TItem extends ListItem>({
36
37
const theme = useTheme ( ) ;
37
38
const styles = useThemeStyles ( ) ;
38
39
const { hovered, bind} = useHover ( ) ;
40
+ const { isMouseDownOnInput, setMouseUp} = useMouseContext ( ) ;
39
41
40
42
const pressableRef = useRef < View > ( null ) ;
41
43
42
44
// Sync focus on an item
43
45
useSyncFocus ( pressableRef , Boolean ( isFocused ) , shouldSyncFocus ) ;
46
+ const handleMouseUp = ( e : React . MouseEvent < Element , MouseEvent > ) => {
47
+ e . stopPropagation ( ) ;
48
+ setMouseUp ( ) ;
49
+ } ;
44
50
45
51
const rightHandSideComponentRender = ( ) => {
46
52
if ( canSelectMultiple || ! rightHandSideComponent ) {
@@ -67,6 +73,10 @@ function BaseListItem<TItem extends ListItem>({
67
73
{ ...bind }
68
74
ref = { pressableRef }
69
75
onPress = { ( e ) => {
76
+ if ( isMouseDownOnInput ) {
77
+ e ?. stopPropagation ( ) ; // Preventing the click action
78
+ return ;
79
+ }
70
80
if ( shouldPreventEnterKeySubmit && e && 'key' in e && e . key === CONST . KEYBOARD_SHORTCUTS . ENTER . shortcutKey ) {
71
81
return ;
72
82
}
@@ -82,6 +92,8 @@ function BaseListItem<TItem extends ListItem>({
82
92
id = { keyForList ?? '' }
83
93
style = { pressableStyle }
84
94
onFocus = { onFocus }
95
+ onMouseUp = { handleMouseUp }
96
+ onMouseLeave = { handleMouseUp }
85
97
tabIndex = { item . tabIndex }
86
98
>
87
99
< View style = { wrapperStyle } >
0 commit comments