From 444a3c29ef94def37c66d43b054b3e71c2f0a713 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Mon, 31 Aug 2020 09:51:21 +0200 Subject: [PATCH] Fixing a bug for component configs edit (no files selected before) --- src/componentconfig/edit-config.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/componentconfig/edit-config.js b/src/componentconfig/edit-config.js index 51c4761..2277331 100644 --- a/src/componentconfig/edit-config.js +++ b/src/componentconfig/edit-config.js @@ -53,8 +53,13 @@ class EditConfigDialog extends React.Component { for(let e of this.state.selectedFiles){ IDs.push(e.id) } - if (JSON.stringify(IDs) !== JSON.stringify(this.props.config.fileIDs)){ - data.fileIDs = IDs; + if(this.props.config.fileIDs !== null && this.props.config.fileIDs !== undefined) { + if (JSON.stringify(IDs) !== JSON.stringify(this.props.config.fileIDs)) { + data.fileIDs = IDs; + } + } + else{ + data.fileIDs = IDs } //forward modified config to callback function @@ -96,10 +101,12 @@ class EditConfigDialog extends React.Component { // determine list of selected files incl id and filename let selectedFiles = [] - for(let selectedFileID of this.props.config.fileIDs){ - for (let file of this.props.files){ - if (file.id === selectedFileID){ - selectedFiles.push({name: file.name, id: file.id}) + if(this.props.config.fileIDs !== null && this.props.config.fileIDs !== undefined) { + for (let selectedFileID of this.props.config.fileIDs) { + for (let file of this.props.files) { + if (file.id === selectedFileID) { + selectedFiles.push({name: file.name, id: file.id}) + } } } }