diff --git a/ui/src/formkit/inputs/select/SelectMain.vue b/ui/src/formkit/inputs/select/SelectMain.vue index 44ef2ae4d..b5cbabae4 100644 --- a/ui/src/formkit/inputs/select/SelectMain.vue +++ b/ui/src/formkit/inputs/select/SelectMain.vue @@ -555,6 +555,22 @@ watch( } ); +const enableAutoSelect = () => { + if (!selectProps.autoSelect) { + return false; + } + if (selectProps.multiple || selectProps.placeholder) { + return false; + } + + const value = props.context.node.value; + if (value === void 0 || value === null) { + return true; + } + + return false; +}; + watch( () => options.value, async (newOptions) => { @@ -563,13 +579,8 @@ watch( if (selectedOption) { selectOptions.value = selectedOption; } - const isAutoSelect = - selectProps.autoSelect && - !selectProps.multiple && - !selectProps.placeholder && - !props.context.node.value; - if (isAutoSelect) { + if (enableAutoSelect()) { // Automatically select the first option when the selected value is empty. const autoSelectedOption = getAutoSelectedOption(); if (autoSelectedOption) {