From 28e3a38d2b27a3e97c5c532f522db17d9991d4bf Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 3 May 2024 12:59:15 +0200 Subject: [PATCH] Improve readability --- .../src/components/app/forms/RelationshipField.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/app/forms/RelationshipField.svelte b/packages/client/src/components/app/forms/RelationshipField.svelte index 9439fd2239..f8a84a00cb 100644 --- a/packages/client/src/components/app/forms/RelationshipField.svelte +++ b/packages/client/src/components/app/forms/RelationshipField.svelte @@ -59,10 +59,10 @@ if (primaryDisplay && fieldState && !optionsObj) { // Persist the initial values as options, allowing them to be present in the dropdown, // even if they are not in the inital fetch results - const valueAsSafeArray = - (!fieldState.value || Array.isArray(fieldState.value) - ? fieldState.value - : [fieldState.value]) || [] + let valueAsSafeArray = fieldState.value || [] + if (!Array.isArray(fieldState.value)) { + valueAsSafeArray = [fieldState.value] + } optionsObj = valueAsSafeArray.reduce((accumulator, value) => { // fieldState has to be an array of strings to be valid for an update // therefore we cannot guarantee value will be an object