Add workaround for error update

This commit is contained in:
Paulo Gustavo Veiga 2022-02-17 18:04:28 -08:00
parent a50ee13589
commit a5847c64d4
3 changed files with 25 additions and 11 deletions

View File

@ -30,9 +30,16 @@ import Topic from './Topic';
abstract class ActionDispatcher extends Events {
private static _instance: ActionDispatcher;
private _commandContext: CommandContext;
constructor(commandContext: CommandContext) {
$assert(commandContext, 'commandContext can not be null');
super();
this._commandContext = commandContext;
}
getCommandContext(): CommandContext {
return this._commandContext;
}
abstract addRelationship(model: RelationshipModel, mindmap: Mindmap): void;

View File

@ -40,7 +40,6 @@ class CommandContext {
this._designer = value;
}
/** */
findTopics(topicIds: number[]): Topic[] {
$assert($defined(topicIds), 'topicsIds can not be null');
const topicsIds = Array.isArray(topicIds) ? topicIds : [topicIds];

View File

@ -22,6 +22,7 @@ import initHotKeyPluggin from '../../../../libraries/jquery.hotkeys';
import Events from './Events';
import ActionDispatcher from './ActionDispatcher';
import Topic from './Topic';
import { Designer } from '..';
initHotKeyPluggin($);
@ -255,18 +256,25 @@ class MultilineTextEditor extends Events {
close(update: boolean): void {
if (this.isVisible() && this._topic) {
if (!$defined(update) || update) {
const actionDispatcher = ActionDispatcher.getInstance();
// Workaround. For some reason, close is triggered but the topic has been removed. Temporally, try to validate if exits.
try {
actionDispatcher
.getCommandContext()
.findTopics([this._topic.getId()]);
this._updateModel();
}
// Let make the visible text in the node visible again ...
// Let make the visible text in the node ...
this._topic.getTextShape().setVisibility(true);
} catch (e) {
console.log(e);
}
// Remove it form the screen ...
this._containerElem.remove();
this._containerElem = null;
}
this._topic = null;
}
}
}
export default MultilineTextEditor;