mirror of https://github.com/halo-dev/halo
[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
parent
7f68de392a
commit
527a49e3b8
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue