1
0
Fork 0
mirror of synced 2024-09-18 10:20:11 +12:00

Improve readability

This commit is contained in:
Adria Navarro 2024-05-03 12:59:15 +02:00
parent f9d738c393
commit 28e3a38d2b

View file

@ -59,10 +59,10 @@
if (primaryDisplay && fieldState && !optionsObj) { if (primaryDisplay && fieldState && !optionsObj) {
// Persist the initial values as options, allowing them to be present in the dropdown, // Persist the initial values as options, allowing them to be present in the dropdown,
// even if they are not in the inital fetch results // even if they are not in the inital fetch results
const valueAsSafeArray = let valueAsSafeArray = fieldState.value || []
(!fieldState.value || Array.isArray(fieldState.value) if (!Array.isArray(fieldState.value)) {
? fieldState.value valueAsSafeArray = [fieldState.value]
: [fieldState.value]) || [] }
optionsObj = valueAsSafeArray.reduce((accumulator, value) => { optionsObj = valueAsSafeArray.reduce((accumulator, value) => {
// fieldState has to be an array of strings to be valid for an update // fieldState has to be an array of strings to be valid for an update
// therefore we cannot guarantee value will be an object // therefore we cannot guarantee value will be an object