Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auto-complete): use option prop's value instead of label fo…
Browse files Browse the repository at this point in the history
…r update value, closes #5794
jizai1125 committed Mar 20, 2024
1 parent a2561cd commit dd6f18e
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
- Fix `useModal` setting `card` preset without corresponding props in `n-card` slots, closes [#5746](https://github.com/tusen-ai/naive-ui/issues/5746).
- Fix `Submenu` component's wai-aria role setting error of `n-menu`,closes [#5729](https://github.com/tusen-ai/naive-ui/issues/5729).
- Fix the `common` type error in the `theme-overrides` prop when modifying components' themes.
- Fix `n-auto-complete` should use `option` prop's `value` instead of `label` for update value, closes [5794](https://github.com/tusen-ai/naive-ui/issues/5794).

### Features

1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
- 修复 `n-dialog` / `n-modal` 调用 `destroy` 方法时可能会报错
- 修复 `useModal` 设置 `card` 预设时 `n-card` 插槽缺少相应属性,关闭 [#5746](https://github.com/tusen-ai/naive-ui/issues/5746)
- 修复组件调整主题时 `theme-overrides` 属性中的 `common` 类型报错
- 修复 `n-auto-complete` 更新值应使用 `option` 属性的 `value` 而非 `label`, 关闭 [5794](https://github.com/tusen-ai/naive-ui/issues/5794)

### Features

9 changes: 3 additions & 6 deletions src/auto-complete/src/AutoComplete.tsx
Original file line number Diff line number Diff line change
@@ -238,14 +238,11 @@ export default defineComponent({
function select (option: AutoCompleteOption): void {
if (option?.value !== undefined) {
doSelect(option.value)
doUpdateValue(
props.append ? `${mergedValueRef.value}${option.value}` : option.value
)
if (props.clearAfterSelect) {
doUpdateValue(null)
} else if (option.label !== undefined) {
doUpdateValue(
props.append
? `${mergedValueRef.value}${option.label}`
: option.label
)
}
canBeActivatedRef.value = false
if (props.blurAfterSelect) {

0 comments on commit dd6f18e

Please sign in to comment.