2 Commits

Author SHA1 Message Date
Eric Tuvesson
ac7b979945 fix(runtime): Close Popup node with no actions causing error
https://github.com/fluxscape/fluxscape/pull/78
2024-10-03 11:28:04 +02:00
Eric Tuvesson
fff03c05bf 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)
2024-10-03 11:24:57 +02:00
3 changed files with 21 additions and 6 deletions

View File

@@ -5,9 +5,14 @@ const navigation = {
async showPopup(componentPath, params) {
return new Promise((resolve) => {
navigation._noodlRuntime.context.showPopup(componentPath, params, {
senderNode: this.nodeScope.componentOwner,
/**
* @param {string | undefined} action
* @param {*} results
*/
onClosePopup: (action, results) => {
resolve({
action: action.replace('closeAction-', ''),
action: (action || '').replace('closeAction-', ''),
parameters: results
});
}

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);
}
}
});
},