docs: add input showCount lose focus desc. close #35080

This commit is contained in:
zombiej 2022-04-20 10:33:42 +08:00
parent 1349b99122
commit 5dfa8678c0
2 changed files with 4 additions and 4 deletions

View File

@ -96,9 +96,9 @@ Supports all props of `Input`.
## FAQ
### Why Input lose focus when change `prefix/suffix`
### Why Input lose focus when change `prefix/suffix/showCount`
When Input dynamic add or remove `prefix/suffix` will make React recreate the dom structure and new input will be not focused. You can set an empty `<span />` element to keep the dom structure:
When Input dynamic add or remove `prefix/suffix/showCount` will make React recreate the dom structure and new input will be not focused. You can set an empty `<span />` element to keep the dom structure:
```jsx
const suffix = condition ? <Icon type="smile" /> : <span />;

View File

@ -97,9 +97,9 @@ Input 的其他属性和 React 自带的 [input](https://reactjs.org/docs/dom-el
## FAQ
### 为什么我动态改变 `prefix/suffix` 时Input 会失去焦点?
### 为什么我动态改变 `prefix/suffix/showCount` 时Input 会失去焦点?
当 Input 动态添加或者删除 `prefix/suffix` 时React 会重新创建 DOM 结构而新的 input 是没有焦点的。你可以预设一个空的 `<span />` 来保持 DOM 结构不变:
当 Input 动态添加或者删除 `prefix/suffix/showCount` 时React 会重新创建 DOM 结构而新的 input 是没有焦点的。你可以预设一个空的 `<span />` 来保持 DOM 结构不变:
```jsx
const suffix = condition ? <Icon type="smile" /> : <span />;