[release-2.19] fix: formkit selector not listening to data after defaulting to first option (#6574)

This is an automated cherry-pick of #6571

/assign LIlGG

```release-note
解决 formkit 选择器回显数据异常的问题
```
pull/6576/head
Halo Dev Bot 2024-09-02 17:07:37 +08:00 committed by GitHub
parent 142f46b435
commit a0af1c2f4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -576,9 +576,15 @@ watch(
}
);
const handleSelectedUpdate = (
value: Array<{ label: string; value: string }>
) => {
stopSelectedWatch();
handleUpdate(value);
};
const handleUpdate = (value: Array<{ label: string; value: string }>) => {
const values = value.map((item) => item.value);
stopSelectedWatch();
selectOptions.value = value;
if (selectProps.multiple) {
props.context.node.input(values);
@ -714,7 +720,7 @@ const handleNextPage = async () => {
:clearable="selectProps.clearable"
:searchable="selectProps.searchable"
:auto-select="selectProps.autoSelect"
@update="handleUpdate"
@update="handleSelectedUpdate"
@search="handleSearch"
@load-more="handleNextPage"
/>