fix: remove invisible elements safely (#7083)

This commit is contained in:
David Luzar 2023-10-04 16:09:59 +02:00 committed by GitHub
parent 1f4f5e11ae
commit 8b838049df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -90,7 +90,9 @@ export const actionFinalize = register({
} }
} }
if (isInvisiblySmallElement(multiPointElement)) { if (isInvisiblySmallElement(multiPointElement)) {
newElements = newElements.slice(0, -1); newElements = newElements.filter(
(el) => el.id !== multiPointElement.id,
);
} }
// If the multi point line closes the loop, // If the multi point line closes the loop,

View File

@ -6549,7 +6549,9 @@ class App extends React.Component<AppProps, AppState> {
) { ) {
// remove invisible element which was added in onPointerDown // remove invisible element which was added in onPointerDown
this.scene.replaceAllElements( this.scene.replaceAllElements(
this.scene.getElementsIncludingDeleted().slice(0, -1), this.scene
.getElementsIncludingDeleted()
.filter((el) => el.id !== draggingElement.id),
); );
this.setState({ this.setState({
draggingElement: null, draggingElement: null,