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) => { private onTapEnd = (event: TouchEvent) => {
this.resetContextMenuTimer();
if (event.touches.length > 0) { if (event.touches.length > 0) {
this.setState({ this.setState({
previousSelectedElementIds: {}, previousSelectedElementIds: {},
selectedElementIds: this.state.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) => { removePointer = (event: React.PointerEvent<HTMLElement> | PointerEvent) => {
// remove touch handler for context menu on touch devices if (touchTimeout) {
if (event.pointerType === "touch" && touchTimeout) { this.resetContextMenuTimer();
clearTimeout(touchTimeout);
touchTimeout = 0;
invalidateContextMenu = false;
} }
gesture.pointers.delete(event.pointerId); 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( private maybeCleanupAfterMissingPointerUp(
event: React.PointerEvent<HTMLCanvasElement>, event: React.PointerEvent<HTMLCanvasElement>,
): void { ): void {