@@ -27,7 +27,15 @@ const handleRouting = (event, { replace, to }, history) => {
2727
2828export default function useActionElement ( Component , props , ref ) {
2929 // eslint-disable-next-line react/prop-types
30- const { to, replace, external, onPress, keepFocus, ...elementProps } = props ;
30+ const {
31+ to,
32+ replace,
33+ external,
34+ onPress,
35+ onClick,
36+ keepFocus,
37+ ...elementProps
38+ } = props ;
3139
3240 const { history, location } = useContext ( RouterContext ) ;
3341
@@ -59,8 +67,13 @@ export default function useActionElement(Component, props, ref) {
5967 { ...elementProps }
6068 ref = { handleRef }
6169 accessibilityRole = "button"
62- onPress = { event => {
63- handlePress ( event , props , internalRef ) ;
70+ onClick = { event => {
71+ // We use the onClick event for buttons instead of onPress, because
72+ // if the mouse moves while clicking the click is not detected.
73+ // See https://github.com/necolas/react-native-web/issues/1219
74+ handlePress ( { } , props , internalRef ) ;
75+
76+ if ( onClick ) onClick ( event ) ;
6477 } }
6578 tabIndex = { 0 }
6679 essentials = { essentials }
@@ -79,6 +92,7 @@ export default function useActionElement(Component, props, ref) {
7992 onPress = { event => {
8093 handlePress ( event , props , internalRef ) ;
8194 } }
95+ onClick = { onClick }
8296 target = "_blank"
8397 rel = "noopener noreferrer"
8498 essentials = { essentials }
@@ -101,6 +115,7 @@ export default function useActionElement(Component, props, ref) {
101115 handlePress ( event , props , internalRef ) ;
102116 handleRouting ( event , props , history ) ;
103117 } }
118+ onClick = { onClick }
104119 essentials = { essentials }
105120 />
106121 ) ;
0 commit comments