Reset selectedElementIds when deleting selected elements (#875)
This commit is contained in:
parent
ccbbdb75a6
commit
c89584832d
@ -9,9 +9,17 @@ import { register } from "./register";
|
|||||||
export const actionDeleteSelected = register({
|
export const actionDeleteSelected = register({
|
||||||
name: "deleteSelectedElements",
|
name: "deleteSelectedElements",
|
||||||
perform: (elements, appState) => {
|
perform: (elements, appState) => {
|
||||||
|
const {
|
||||||
|
elements: nextElements,
|
||||||
|
appState: nextAppState,
|
||||||
|
} = deleteSelectedElements(elements, appState);
|
||||||
return {
|
return {
|
||||||
elements: deleteSelectedElements(elements, appState),
|
elements: nextElements,
|
||||||
appState: { ...appState, elementType: "selection", multiElement: null },
|
appState: {
|
||||||
|
...nextAppState,
|
||||||
|
elementType: "selection",
|
||||||
|
multiElement: null,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
contextItemLabel: "labels.delete",
|
contextItemLabel: "labels.delete",
|
||||||
|
@ -180,9 +180,13 @@ export class App extends React.Component<any, AppState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
copyToAppClipboard(elements, this.state);
|
copyToAppClipboard(elements, this.state);
|
||||||
elements = deleteSelectedElements(elements, this.state);
|
const { elements: nextElements, appState } = deleteSelectedElements(
|
||||||
|
elements,
|
||||||
|
this.state,
|
||||||
|
);
|
||||||
|
elements = nextElements;
|
||||||
history.resumeRecording();
|
history.resumeRecording();
|
||||||
this.setState({});
|
this.setState({ ...appState });
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
};
|
};
|
||||||
private onCopy = (event: ClipboardEvent) => {
|
private onCopy = (event: ClipboardEvent) => {
|
||||||
|
@ -34,7 +34,13 @@ export function deleteSelectedElements(
|
|||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
) {
|
) {
|
||||||
return elements.filter(el => !appState.selectedElementIds[el.id]);
|
return {
|
||||||
|
elements: elements.filter(el => !appState.selectedElementIds[el.id]),
|
||||||
|
appState: {
|
||||||
|
...appState,
|
||||||
|
selectedElementIds: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSelectedIndices(
|
export function getSelectedIndices(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user