From 8da2baf6d5f3c306ebd0a438aa611f9b42aefeb8 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Mon, 25 Mar 2024 14:11:13 -0700 Subject: [PATCH] Hide disabled properties on the preform --- src/renderer/src/stories/JSONSchemaForm.js | 4 ++++ .../src/stories/pages/guided-mode/setup/Preform.js | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index 327a1afaa..20dce8ec2 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -113,6 +113,10 @@ const componentCSS = ` gap: 10px; } + .form-section[hidden] { + display: none; + } + #empty { display: flex; align-items: center; diff --git a/src/renderer/src/stories/pages/guided-mode/setup/Preform.js b/src/renderer/src/stories/pages/guided-mode/setup/Preform.js index a298f026a..a535c9356 100644 --- a/src/renderer/src/stories/pages/guided-mode/setup/Preform.js +++ b/src/renderer/src/stories/pages/guided-mode/setup/Preform.js @@ -21,7 +21,6 @@ const questions = { condition: [false, undefined], default: "", required: true, - attribute: "hidden", }, }, }, @@ -33,7 +32,6 @@ const questions = { condition: [false, undefined], default: "", required: true, - attribute: "hidden", }, }, }, @@ -127,8 +125,9 @@ export class GuidedPreform extends Page { }); const dependentEl = this.inputs[dependent.name]; + const dependentParent = dependentEl.parentElement - const attr = dependent.attribute ?? "disabled"; + const attr = dependent.attribute ?? "hidden"; let condition = (v) => !!v; if (!("condition" in dependent)) { @@ -138,13 +137,13 @@ export class GuidedPreform extends Page { else console.warn("Invalid condition", dependent.condition); if (uniformDeps.every(({ name }) => condition(parent[name]))) { - dependentEl.removeAttribute(attr); + dependentParent.removeAttribute(attr); if ("required" in dependent) dependentEl.required = dependent.required; if ("__cached" in dependent) dependentEl.updateData(dependent.__cached); } else { if (dependentEl.value !== undefined) dependent.__cached = dependentEl.value; dependentEl.updateData(dependent.default); - dependentEl.setAttribute(attr, true); + dependentParent.setAttribute(attr, true); if ("required" in dependent) dependentEl.required = !dependent.required; } });