Fix potential crash when deleting events or instructions

This commit is contained in:
Florian Rival
2019-01-27 23:54:56 +00:00
parent 2b40f57189
commit 3fd032d898

View File

@@ -521,14 +521,20 @@ export default class EventsSheet extends React.Component<Props, State> {
);
eventsRemover.launch(events);
this.setState({
selection: clearSelection(),
inlineEditing: false,
inlineEditingAnchorEl: null,
});
this._saveChangesToHistory(() => {
if (this._eventsTree) this._eventsTree.forceEventsUpdate();
});
// /!\ Events were changed, so any reference to an existing event can now
// be invalid. Make sure to immediately trigger a forced update before
// any re-render that could use a deleted/invalid event.
if (this._eventsTree) this._eventsTree.forceEventsUpdate();
this.setState(
{
selection: clearSelection(),
inlineEditing: false,
inlineEditingAnchorEl: null,
},
() => this._saveChangesToHistory()
);
};
copySelection = () => {