fix: contextMenu timer & pointers not correctly reset on iOS (#4765)

This commit is contained in:
David Luzar 2022-02-09 20:42:02 +01:00 committed by GitHub
parent 0cdd0eebf1
commit 9653d676fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1315,11 +1315,14 @@ class App extends React.Component<AppProps, AppState> {
};
private onTapEnd = (event: TouchEvent) => {
this.resetContextMenuTimer();
if (event.touches.length > 0) {
this.setState({
previousSelectedElementIds: {},
selectedElementIds: this.state.previousSelectedElementIds,
});
} else {
gesture.pointers.clear();
}
};
@ -1532,11 +1535,8 @@ class App extends React.Component<AppProps, AppState> {
};
removePointer = (event: React.PointerEvent<HTMLElement> | PointerEvent) => {
// remove touch handler for context menu on touch devices
if (event.pointerType === "touch" && touchTimeout) {
clearTimeout(touchTimeout);
touchTimeout = 0;
invalidateContextMenu = false;
if (touchTimeout) {
this.resetContextMenuTimer();
}
gesture.pointers.delete(event.pointerId);
@ -2937,6 +2937,12 @@ class App extends React.Component<AppProps, AppState> {
}
};
private resetContextMenuTimer = () => {
clearTimeout(touchTimeout);
touchTimeout = 0;
invalidateContextMenu = false;
};
private maybeCleanupAfterMissingPointerUp(
event: React.PointerEvent<HTMLCanvasElement>,
): void {