Skip to content

Commit

Permalink
enhance: radio add click event
Browse files Browse the repository at this point in the history
  • Loading branch information
1587315093 committed Jul 4, 2023
1 parent 9eae10e commit 46963a8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/radio/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type RadioValue = string | number
| icon | Customized `icon` icon | `(checked: boolean) => React.ReactNode` | - |
| id | The id of the input element, often used in conjunction with the label | `string` | - |
| onChange | Callback function when checked is changed | `(val: boolean) => void` | - |
| onClick | Radio's click event | `(event: React.MouseEvent<HTMLLabelElement, MouseEvent>) => void` | - |
| value | Value is carrying identification, used in `Group` mode | `RadioValue` | - |
### Radio.Group
Expand Down
1 change: 1 addition & 0 deletions src/components/radio/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type RadioValue = string | number
| icon | 自定义 `icon` 图标 | `(checked: boolean) => React.ReactNode` | - |
| id | `input` 元素的 `id`,常用来配合 `label` 使用 | `string` | - |
| onChange | 变化时回调函数 | `(val: boolean) => void` | - |
| onClick | Radio 的点击事件 | `(event: React.MouseEvent<HTMLLabelElement, MouseEvent>) => void` | - |
| value | 携带的标识值,用于 `Group` 模式 | `RadioValue` | - |
### Radio.Group
Expand Down
5 changes: 2 additions & 3 deletions src/components/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type RadioProps = {
id?: string
icon?: (checked: boolean) => React.ReactNode
children?: React.ReactNode
onClick?: (event: React.MouseEvent<HTMLLabelElement, MouseEvent>) => void
} & NativeProps<'--icon-size' | '--font-size' | '--gap'>

const defaultProps = {
Expand Down Expand Up @@ -86,9 +87,7 @@ export const Radio: FC<RadioProps> = p => {
return withNativeProps(
props,
<label
onClick={e => {
e.stopPropagation()
}}
onClick={props.onClick}
className={classNames(classPrefix, {
[`${classPrefix}-checked`]: checked,
[`${classPrefix}-disabled`]: disabled,
Expand Down

0 comments on commit 46963a8

Please sign in to comment.