Fix NPE on remove node.

This commit is contained in:
Paulo Gustavo Veiga 2022-10-07 21:00:54 -07:00
parent c9c2194a57
commit 49de0b4945
4 changed files with 12 additions and 3 deletions

View File

@ -55,7 +55,8 @@ export class DefaultWidgetManager extends WidgetManager {
return topic.getNoteValue();
},
setValue(value: string) {
topic.setNoteValue(value);
const note = value && value.trim() !== '' ? value : undefined;
topic.setNoteValue(note);
},
};
this.editorContent = noteContent(model, () => this.setPopoverOpen(false));

View File

@ -16,9 +16,11 @@ const SaveAndDelete = (props: {
<Button color="primary" variant="outlined" onClick={props.submitHandler} sx={{ mr: 1 }}>
{$msg('ACCEPT')}
</Button>
<Button color="primary" variant="contained" onClick={props.closeModal}>
{$msg('CANCEL')}
</Button>
{props.model.getValue() && props.model.getValue().trim() !== '' && (
<IconButton
onClick={() => {

View File

@ -164,7 +164,11 @@ export class NodePropertyValueModelBuilder {
this.linkModel = {
getValue: (): string => this.selectedTopic()?.getLinkValue(),
setValue: (value: string) => {
this.selectedTopic().setLinkValue(value);
if (value && value.trim() !== '') {
this.selectedTopic().setLinkValue(value);
} else {
this.selectedTopic().setLinkValue(undefined);
}
},
};
return this.linkModel;
@ -218,7 +222,8 @@ export class NodePropertyValueModelBuilder {
this.noteModel = {
getValue: (): string => this.selectedTopic()?.getNoteValue(),
setValue: (value: string) => {
this.selectedTopic().setNoteValue(value);
const note = value && value.trim() !== '' ? value : undefined;
this.selectedTopic()?.setNoteValue(note);
},
};
return this.noteModel;

View File

@ -777,6 +777,7 @@ abstract class Topic extends NodeGraph {
const model = this.getModel();
const dispatcher = ActionDispatcher.getInstance();
const links = model.findFeatureByType(TopicFeatureFactory.Link.id);
if (!$defined(value)) {
const featureId = links[0].getId();
dispatcher.removeFeatureFromTopic(topicId, featureId);