Skip to content

Commit

Permalink
fix: correct boolean value display issue in formkit selector component (
Browse files Browse the repository at this point in the history
#6624)

#### What type of PR is this?

/kind bug
/area ui
/milestone 2.20.x

#### What this PR does / why we need it:

解决 Formkit Selector 在值为布尔或者数字类型时,回显时内容不正常的问题。

#### How to test it?

测试当 FormKit Select 组件的值为布尔或者数字时,回显的内容是否正常。 

#### Does this PR introduce a user-facing change?
```release-note
修复 FormKit Select 组件中布尔值的显示问题。
```
  • Loading branch information
LIlGG authored Sep 10, 2024
1 parent 93ffb7d commit 3c785cb
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ui/src/formkit/inputs/select/SelectMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) {
Expand Down

0 comments on commit 3c785cb

Please sign in to comment.