Skip to content

Commit

Permalink
fix: 🐛 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed Jul 28, 2023
1 parent fa66e01 commit 19d0d99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/common/Check.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef, useContext, MouseEvent } from 'react';
import React, { forwardRef, useContext, MouseEvent, ChangeEvent } from 'react';
import classNames from 'classnames';
import isBoolean from 'lodash/isBoolean';
import { omit } from '../_util/helper';
Expand Down Expand Up @@ -53,9 +53,7 @@ const Check = forwardRef<HTMLLabelElement, CheckProps>((_props, ref) => {

const TOnChange: (
checked: boolean,
context: {
e: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLInputElement>;
},
context: { e: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLInputElement> },
) => void = onChange;

const [internalChecked, setInternalChecked] = useControlled(props, 'checked', TOnChange);
Expand Down Expand Up @@ -90,9 +88,11 @@ const Check = forwardRef<HTMLLabelElement, CheckProps>((_props, ref) => {
// Checkbox/ Radio 内容为空则不再渲染 span,不存在 0:Number 的情况
const showLabel = !!(children || label);

const handleLabelClick = (event) => {
const handleLabelClick = (event: MouseEvent<HTMLSpanElement>) => {
// 在tree等组件中使用 阻止label触发checked 与expand冲突
if (props.stopLabelTrigger) event.preventDefault();
if (props.stopLabelTrigger) {
event.preventDefault();
}
};

const onInnerClick = (e: MouseEvent<HTMLLabelElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion src/radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Radio = forwardRefWithStatics(
{
Group: RadioGroup,
Button: forwardRef<HTMLLabelElement, RadioProps>((props, ref) => (
<Check ref={ref} type="radio-button" {...useDefaultProps<RadioProps>(props, radioDefaultProps)} />
<Check ref={ref} type="radio-button" {...props} />
)),
},
);
Expand Down

0 comments on commit 19d0d99

Please sign in to comment.