diff --git a/src/components/search-bar/demos/demo1.tsx b/src/components/search-bar/demos/demo1.tsx index e10ca2951f..e0c03aa92c 100644 --- a/src/components/search-bar/demos/demo1.tsx +++ b/src/components/search-bar/demos/demo1.tsx @@ -13,7 +13,7 @@ export default () => { - + diff --git a/src/components/search-bar/index.en.md b/src/components/search-bar/index.en.md index ca7c5877c6..6649a2e22c 100644 --- a/src/components/search-bar/index.en.md +++ b/src/components/search-bar/index.en.md @@ -34,7 +34,7 @@ Narrow down the information pool to get targeted information quickly and easily. | showCancelButton | Whether to display the cancel button on the right side of the search input | `boolean \| ((focus: boolean, value: string) => boolean)` | `false` | | value | Input value | `string` | - | -In addition, the following native attributes are supported: `onCompositionStart` `onCompositionEnd` +In addition, the following native attributes are supported: `onCompositionStart` `onCompositionEnd` `autoFocus` ### CSS Variables diff --git a/src/components/search-bar/index.zh.md b/src/components/search-bar/index.zh.md index de6a440492..46fe41189f 100644 --- a/src/components/search-bar/index.zh.md +++ b/src/components/search-bar/index.zh.md @@ -34,7 +34,7 @@ | showCancelButton | 是否在搜索框右侧显示取消按钮 | `boolean \| ((focus: boolean, value: string) => boolean)` | `false` | | value | 输入值 | `string` | - | -此外还支持以下原生属性:`onCompositionStart` `onCompositionEnd` +此外还支持以下原生属性:`onCompositionStart` `onCompositionEnd` `autoFocus` ### CSS 变量 diff --git a/src/components/search-bar/search-bar.tsx b/src/components/search-bar/search-bar.tsx index 3ebca2a06a..1290fe7721 100644 --- a/src/components/search-bar/search-bar.tsx +++ b/src/components/search-bar/search-bar.tsx @@ -15,7 +15,12 @@ export type SearchBarRef = InputRef export type SearchBarProps = Pick< InputProps, - 'onFocus' | 'onBlur' | 'onClear' | 'onCompositionStart' | 'onCompositionEnd' + | 'onFocus' + | 'onBlur' + | 'onClear' + | 'onCompositionStart' + | 'onCompositionEnd' + | 'autoFocus' > & { value?: string defaultValue?: string @@ -133,6 +138,7 @@ export const SearchBar = forwardRef( value={value} onChange={setValue} maxLength={mergedProps.maxLength} + autoFocus={mergedProps.autoFocus} placeholder={mergedProps.placeholder} clearable={mergedProps.clearable} onlyShowClearWhenFocus={mergedProps.onlyShowClearWhenFocus}