mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Fix on(Long)PressChange events in experimental press event API (#15256)
Make sure that `onPressChange` is only called if `longPressCancelsPress` is `false`. And make sure that `onLongPressChange` is called when a long press ends.
This commit is contained in:
1 parent
a41b217708
commit
f4625f5182
1 file changed
+13
-2
Vendored
+13
-2
@@ -80,7 +80,7 @@ function dispatchPressInEvents(
|
||||
true,
|
||||
);
|
||||
}
|
||||
if (props.onLongPress) {
|
||||
if (props.onLongPress && !props.longPressCancelsPress) {
|
||||
const longPressEventListener = e => {
|
||||
props.onLongPress(e);
|
||||
if (e.nativeEvent.defaultPrevented) {
|
||||
@@ -110,7 +110,7 @@ function dispatchPressOutEvents(
|
||||
true,
|
||||
);
|
||||
}
|
||||
if (props.onPressChange) {
|
||||
if (props.onPressChange && !props.longPressCancelsPress) {
|
||||
const pressChangeEventListener = () => {
|
||||
props.onPressChange(false);
|
||||
};
|
||||
@@ -121,6 +121,17 @@ function dispatchPressOutEvents(
|
||||
true,
|
||||
);
|
||||
}
|
||||
if (state.isLongPressed && props.onLongPressChange) {
|
||||
const longPressChangeEventListener = () => {
|
||||
props.onLongPressChange(false);
|
||||
};
|
||||
context.dispatchEvent(
|
||||
'longpresschange',
|
||||
longPressChangeEventListener,
|
||||
state.pressTarget,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isAnchorTagElement(eventTarget: EventTarget): boolean {
|
||||
|
||||
Reference in new issue
Block a user