fix: disable contextmenu on non-secondary pen events or touch (#4675)

This commit is contained in:
David Luzar 2022-02-07 20:01:36 +01:00 committed by GitHub
parent d450c36581
commit 5007df6522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -5035,6 +5035,16 @@ class App extends React.Component<AppProps, AppState> {
) => { ) => {
event.preventDefault(); event.preventDefault();
if (
(event.nativeEvent.pointerType === "touch" ||
(event.nativeEvent.pointerType === "pen" &&
// always allow if user uses a pen secondary button
event.button !== POINTER_BUTTON.SECONDARY)) &&
this.state.elementType !== "selection"
) {
return;
}
const { x, y } = viewportCoordsToSceneCoords(event, this.state); const { x, y } = viewportCoordsToSceneCoords(event, this.state);
const element = this.getElementAtPosition(x, y, { preferSelected: true }); const element = this.getElementAtPosition(x, y, { preferSelected: true });

View File

@ -24,7 +24,7 @@ export const POINTER_BUTTON = {
WHEEL: 1, WHEEL: 1,
SECONDARY: 2, SECONDARY: 2,
TOUCH: -1, TOUCH: -1,
}; } as const;
export enum EVENT { export enum EVENT {
COPY = "copy", COPY = "copy",