From 37be00307ddcbe25c4200d0b9eef023ec6651d02 Mon Sep 17 00:00:00 2001 From: Pranab Das <31024886+pranabdas@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:51:52 +0800 Subject: [PATCH] SOF-7123: set default data correctly for atomicSpecies --- src/context/providers/HubbardUContextProvider.js | 7 ++++++- src/context/providers/HubbardVContextProvider.js | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/context/providers/HubbardUContextProvider.js b/src/context/providers/HubbardUContextProvider.js index a7419ff..e7709fd 100644 --- a/src/context/providers/HubbardUContextProvider.js +++ b/src/context/providers/HubbardUContextProvider.js @@ -19,7 +19,12 @@ export class HubbardUContextProvider extends mix(JSONSchemaFormDataProvider).wit } get defaultData() { - return [{ ...defaultHubbardConfig, atomicSpecies: this.uniqueElements }]; + return [ + { + ...defaultHubbardConfig, + atomicSpecies: this.uniqueElements?.length > 0 ? this.uniqueElements[0] : "", + }, + ]; } get uiSchemaStyled() { diff --git a/src/context/providers/HubbardVContextProvider.js b/src/context/providers/HubbardVContextProvider.js index dd302b7..1bbf434 100644 --- a/src/context/providers/HubbardVContextProvider.js +++ b/src/context/providers/HubbardVContextProvider.js @@ -12,7 +12,13 @@ const defaultHubbardConfig = { export class HubbardVContextProvider extends HubbardUContextProvider { get defaultData() { - return [{ ...defaultHubbardConfig, atomicSpecies2: this.uniqueElements }]; + return [ + { + ...defaultHubbardConfig, + atomicSpecies: this.uniqueElements?.length > 0 ? this.uniqueElements[0] : "", + atomicSpecies2: this.uniqueElements?.length > 0 ? this.uniqueElements[0] : "", + }, + ]; } get uiSchemaStyled() {