From 11c5ed1f6a87c499d85c8401388f903976bb9368 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 15 Jun 2022 10:17:34 +0100 Subject: [PATCH] Fix issue where required settings that depend on other settings were still blocking rendering --- .../client/src/components/Component.svelte | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index 3fa408c295..c196e2ff64 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -207,10 +207,23 @@ // Check if we have any missing required settings missingRequiredSettings = settingsDefinition.filter(setting => { - return ( - setting.required && - (instance[setting.key] == null || instance[setting.key] === "") - ) + let empty = instance[setting.key] == null || instance[setting.key] === "" + let missing = setting.required && empty + + // Check if this setting depends on another, as it may not be required + if (setting.dependsOn) { + const dependsOnKey = setting.dependsOn.setting || setting.dependsOn + const dependsOnValue = setting.dependsOn.value + const realDependentValue = instance[dependsOnKey] + if (dependsOnValue == null && realDependentValue == null) { + return false + } + if (dependsOnValue !== realDependentValue) { + return false + } + } + + return missing }) // Force an initial enrichment of the new settings