Skip to content

Commit

Permalink
fix: prevent panning to trigger history on macos chrome (excalidraw#7671
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dwelle authored Feb 8, 2024
1 parent def1df2 commit adc4c9f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/excalidraw/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
const selectedElements = this.scene.getSelectedElements(this.state);
const { renderTopRightUI, renderCustomStats } = this.props;
Expand Down Expand Up @@ -1463,6 +1470,8 @@ class App extends React.Component<AppProps, AppState> {
onKeyDown={
this.props.handleKeyboardGlobally ? undefined : this.onKeyDown
}
onPointerEnter={this.toggleOverscrollBehavior}
onPointerLeave={this.toggleOverscrollBehavior}
>
<AppContext.Provider value={this}>
<AppPropsContext.Provider value={this.props}>
Expand Down Expand Up @@ -2455,6 +2464,7 @@ class App extends React.Component<AppProps, AppState> {
isSomeElementSelected.clearCache();
selectGroupsForSelectedElements.clearCache();
touchTimeout = 0;
document.documentElement.style.overscrollBehaviorX = "";
}

private onResize = withBatchedUpdates(() => {
Expand Down

0 comments on commit adc4c9f

Please sign in to comment.