[release-2.19] fix: correct boolean value display issue in formkit selector component (#6630)

This is an automated cherry-pick of #6624

/assign LIlGG

```release-note
修复 FormKit Select 组件中布尔值的显示问题。
```
pull/6631/head
Halo Dev Bot 2024-09-10 16:10:11 +08:00 committed by GitHub
parent 7f68de392a
commit 527a49e3b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 6 deletions

View File

@ -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) {