fix(runtime): Close Popup node with no actions causing error (#78)

TypeError: Cannot read properties of undefined (reading 'replace')
    at Object.onClosePopup (navigation.js:10:1)
    at EventEmitter.<anonymous> (nodecontext.js:491:1)
    at Object.onceWrapper (events.js:242:1)
    at EventEmitter.emit (events.js:153:1)
    at NoodlRuntime._doUpdate (noodl-runtime.js:338:1)
This commit is contained in:
Eric Tuvesson
2024-10-03 11:24:57 +02:00
committed by GitHub
parent 5dbb11bac8
commit fff03c05bf
2 changed files with 15 additions and 5 deletions

View File

@@ -51,8 +51,9 @@ const ClosePopupNode = {
}
},
close: function () {
if (this._internal.closeCallback)
if (this._internal.closeCallback) {
this._internal.closeCallback(this._internal.closeAction, this._internal.resultValues);
}
},
closeActionTriggered: function (name) {
this._internal.closeAction = name;

View File

@@ -53,15 +53,24 @@ const ShowPopupNode = {
this.context.showPopup(this._internal.target, this._internal.popupParams, {
senderNode: this.nodeScope.componentOwner,
/**
* @param {string | undefined} action
* @param {*} results
*/
onClosePopup: (action, results) => {
this._internal.closeResults = results;
for (var key in results) {
if (this.hasOutput('closeResult-' + key)) this.flagOutputDirty('closeResult-' + key);
for (const key in results) {
if (this.hasOutput('closeResult-' + key)) {
this.flagOutputDirty('closeResult-' + key);
}
}
if (!action) this.sendSignalOnOutput('Closed');
else this.sendSignalOnOutput(action);
if (!action) {
this.sendSignalOnOutput('Closed');
} else {
this.sendSignalOnOutput(action);
}
}
});
},