docs: update faq about auto-complete (#44082)

* docs: update faq about auto-complete

* docs: update faq about auto-complete

* docs: update docs

* Update components/auto-complete/index.zh-CN.md

Co-authored-by: afc163 <afc163@gmail.com>
Signed-off-by: kiner-tang(文辉) <1127031143@qq.com>

---------

Signed-off-by: kiner-tang(文辉) <1127031143@qq.com>
Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
kiner-tang(文辉) 2023-08-08 15:33:53 +08:00 committed by GitHub
parent bd1ca16294
commit 7ff17e02a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -86,3 +86,7 @@ The differences with Select are:
Please use `onChange` to manage control state. `onSearch` is used for searching input which is not the same as `onChange`. Besides, clicking on the option will not trigger the `onSearch` event.
Related issue: [#18230](https://github.com/ant-design/ant-design/issues/18230) [#17916](https://github.com/ant-design/ant-design/issues/17916)
### Why won't a controlled open AutoComplete display a drop-down menu when options are empty?
The AutoComplete component is essentially an extension of the Input form element. When the `options` property is empty, displaying empty text could mislead the user into believing the component is not operational, when in fact they are still able to input text. To avoid confusion, the `open` property will not display the drop-down menu when set to `true` and in combination with an empty `options` property. The `open` property must be used in conjunction with the `options` property.

View File

@ -88,3 +88,7 @@ demo:
请使用 `onChange` 进行受控管理。`onSearch` 触发于搜索输入,与 `onChange` 时机不同。此外,点击选项时也不会触发 `onSearch` 事件。
相关 issue[#18230](https://github.com/ant-design/ant-design/issues/18230) [#17916](https://github.com/ant-design/ant-design/issues/17916)
### 为何 options 为空时,受控 open 展开不会显示下拉菜单?
AutoComplete 组件本质上是 Input 输入框的一种扩展,当 `options` 为空时,显示空文本会让用户误以为该组件不可操作,实际上它仍然可以进行文本输入操作。因此,为了避免给用户带来困惑,当 `options` 为空时,`open` 属性为 `true` 也不会展示下拉菜单,需要与 `options` 属性配合使用。