fix: undo redo opens invalid class editor (RDFA-499)#133
Conversation
- class editor closes, when trying to open a nonexisting class
4d52df9 to
4c5f937
Compare
| onDestroy(() => eventStack.removeEvent(closeClassEditor)); | ||
| function withUnsavedChangesCheck(action) { | ||
| if (reactiveClass?.isModified) { | ||
| pendingAction = action; |
There was a problem hiding this comment.
withUnsavedChangesCheck sets pendingAction and opens the dialog, but cancel (closeDialog(onCancel)) and escape never clear pendingAction.
| if (isRedo) { | ||
| if (canRedo && (await redo())) { | ||
| await reload(); | ||
| toastStore.info("Redone"); | ||
| } else if (!canRedo) { | ||
| console.log("Redo blocked: nothing to redo."); | ||
| } | ||
| } else { | ||
| if (canUndo && (await undo())) { | ||
| await reload(); | ||
| toastStore.info("Undone"); | ||
| } else if (!canUndo) { | ||
| console.log("Undo blocked: nothing to undo."); | ||
| } | ||
| } |
There was a problem hiding this comment.
undo/redo are now wrapped in eventStack.guardAction(...) with no return, so they now always resolve to undefined.
So await reload() and toast notifications are now dead.
Reload is still covered with a forceReloadtrigger.trigger() internally, but reload() also did editorState.selectedDataset/Graph/ClassUUID.trigger() and fetchUndoRedo().
But no longer the toasts.
| console.log("Undo failed."); | ||
| toastStore.error("Undo failed", "Could not undo the last change."); | ||
| return false; | ||
| eventStack.guardAction(async () => { |
There was a problem hiding this comment.
GraphSection still relies on the return value.
| isDatasetReadOnly = await isReadOnly(datasetName); | ||
| await loadContext(); | ||
| await loadReactiveClass(cancellation); | ||
| await loadReactiveClass(cancellation, JSON.parse(resText)); |
There was a problem hiding this comment.
!resText handles empty body, not non-empty, non-JSON body.
Maybe try/catch.
| } | ||
|
|
||
| unregisterActionGuard() { | ||
| this.actionGuard = null; |
There was a problem hiding this comment.
Maybe only unregister if actionGuard === fn.
Description
Test Checklist
General Behavior
Global MenuBar
Welcome Page
Editor - MenuBar
Editor - Navigation
Editor - Package View
Editor - Class Editor
Prefixes Page
Changelog Page
Compare Page