Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(button): support autofocus property #3293

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/web-vue/components/button/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ description: Button is a command component that can initiate an instant operatio
|loading|Whether the button is in the loading state|`boolean`|`false`|
|disabled|Whether the button is disabled|`boolean`|`false`|
|html-type|Set the native `type` attribute of `button`, optional values refer to [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type "_blank")|`string`|`'button'`|
|autofocus|Set the native `autofocus` attribute of `button`, optional values refer to [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type "_blank")|`boolean`|`false`|
|href|Set up a jump link. When this property is set, the button is rendered as `<a>`|`string`|`-`|
### `<button>` Events

Expand Down
1 change: 1 addition & 0 deletions packages/web-vue/components/button/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ description: 按钮是一种命令组件,可发起一个即时操作。
|loading|按钮是否为加载中状态|`boolean`|`false`|
|disabled|按钮是否禁用|`boolean`|`false`|
|html-type|设置 `button` 的原生 `type` 属性,可选值参考 [HTML标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type "_blank")|`string`|`'button'`|
|autofocus|设置 `button` 的原生 `autofocus` 属性,可选值参考 [HTML标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type "_blank")|`boolean`|`false`|
|href|设置跳转链接。设置此属性时,按钮渲染为a标签。|`string`|`-`|
### `<button>` Events

Expand Down
9 changes: 9 additions & 0 deletions packages/web-vue/components/button/button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
]"
:type="htmlType"
:disabled="mergedDisabled"
:autofocus="autofocus"
@click="handleClick"
>
<span v-if="loading || $slots.icon" :class="`${prefixCls}-icon`">
Expand Down Expand Up @@ -121,6 +122,14 @@ export default defineComponent({
type: String,
default: 'button',
},
/**
* @zh 设置 `button` 的原生 `autofocus` 属性,可选值参考 [HTML标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type "_blank")
* @en Set the native `autofocus` attribute of `button`, optional values refer to [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type "_blank")
*/
autofocus: {
type: Boolean,
default: false,
},
/**
* @zh 设置跳转链接。设置此属性时,按钮渲染为a标签。
* @en Set up a jump link. When this property is set, the button is rendered as `<a>`
Expand Down
1 change: 1 addition & 0 deletions packages/web-vue/components/button/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export interface ButtonProps {
loading?: boolean;
disabled?: boolean;
htmlType?: string;
autofocus?: boolean;
href?: string;
}