mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: empty snapLines arrays would cause re-render (#7454)
Co-authored-by: Lynda Lin <lynda.lin@optoma.com> Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
parent
7bd6496854
commit
2a0fe2584e
7 changed files with 139 additions and 64 deletions
|
@ -268,6 +268,7 @@ import {
|
|||
muteFSAbortError,
|
||||
isTestEnv,
|
||||
easeOut,
|
||||
updateStable,
|
||||
} from "../utils";
|
||||
import {
|
||||
createSrcDoc,
|
||||
|
@ -4736,13 +4737,31 @@ class App extends React.Component<AppProps, AppState> {
|
|||
event,
|
||||
);
|
||||
|
||||
this.setState({
|
||||
snapLines,
|
||||
originSnapOffset: originOffset,
|
||||
this.setState((prevState) => {
|
||||
const nextSnapLines = updateStable(prevState.snapLines, snapLines);
|
||||
const nextOriginOffset = prevState.originSnapOffset
|
||||
? updateStable(prevState.originSnapOffset, originOffset)
|
||||
: originOffset;
|
||||
|
||||
if (
|
||||
prevState.snapLines === nextSnapLines &&
|
||||
prevState.originSnapOffset === nextOriginOffset
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
snapLines: nextSnapLines,
|
||||
originSnapOffset: nextOriginOffset,
|
||||
};
|
||||
});
|
||||
} else if (!this.state.draggingElement) {
|
||||
this.setState({
|
||||
snapLines: [],
|
||||
this.setState((prevState) => {
|
||||
if (prevState.snapLines.length) {
|
||||
return {
|
||||
snapLines: [],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -7227,7 +7246,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
isRotating,
|
||||
} = this.state;
|
||||
|
||||
this.setState({
|
||||
this.setState((prevState) => ({
|
||||
isResizing: false,
|
||||
isRotating: false,
|
||||
resizingElement: null,
|
||||
|
@ -7241,10 +7260,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||
multiElement || isTextElement(this.state.editingElement)
|
||||
? this.state.editingElement
|
||||
: null,
|
||||
snapLines: [],
|
||||
snapLines: updateStable(prevState.snapLines, []),
|
||||
|
||||
originSnapOffset: null,
|
||||
});
|
||||
}));
|
||||
|
||||
SnapCache.setReferenceSnapPoints(null);
|
||||
SnapCache.setVisibleGaps(null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue