1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-10 11:35:52 +01:00

fix: prevent panning to trigger history on macos chrome (#7671)

This commit is contained in:
David Luzar 2024-02-08 19:50:50 +01:00 committed by GitHub
parent def1df2c68
commit adc4c9f484
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1410,6 +1410,13 @@ class App extends React.Component<AppProps, AppState> {
}); });
}; };
private toggleOverscrollBehavior(event: React.PointerEvent) {
// when pointer inside editor, disable overscroll behavior to prevent
// panning to trigger history back/forward on MacOS Chrome
document.documentElement.style.overscrollBehaviorX =
event.type === "pointerenter" ? "none" : "auto";
}
public render() { public render() {
const selectedElements = this.scene.getSelectedElements(this.state); const selectedElements = this.scene.getSelectedElements(this.state);
const { renderTopRightUI, renderCustomStats } = this.props; const { renderTopRightUI, renderCustomStats } = this.props;
@ -1463,6 +1470,8 @@ class App extends React.Component<AppProps, AppState> {
onKeyDown={ onKeyDown={
this.props.handleKeyboardGlobally ? undefined : this.onKeyDown this.props.handleKeyboardGlobally ? undefined : this.onKeyDown
} }
onPointerEnter={this.toggleOverscrollBehavior}
onPointerLeave={this.toggleOverscrollBehavior}
> >
<AppContext.Provider value={this}> <AppContext.Provider value={this}>
<AppPropsContext.Provider value={this.props}> <AppPropsContext.Provider value={this.props}>
@ -2455,6 +2464,7 @@ class App extends React.Component<AppProps, AppState> {
isSomeElementSelected.clearCache(); isSomeElementSelected.clearCache();
selectGroupsForSelectedElements.clearCache(); selectGroupsForSelectedElements.clearCache();
touchTimeout = 0; touchTimeout = 0;
document.documentElement.style.overscrollBehaviorX = "";
} }
private onResize = withBatchedUpdates(() => { private onResize = withBatchedUpdates(() => {