Skip to content
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
8 changes: 3 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
type = 'checkbox',
title,
onChange,
children,
...inputProps
} = props;

const inputRef = useRef<HTMLInputElement>(null);
const holderRef = useRef<HTMLLabelElement>(null);
const holderRef = useRef<HTMLElement>(null);

const [rawValue, setRawValue] = useMergedState(defaultChecked, {
value: checked,
Expand Down Expand Up @@ -91,7 +90,7 @@ export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
};

return (
<label className={classString} title={title} style={style} ref={holderRef}>
<span className={classString} title={title} style={style} ref={holderRef}>
<input
{...inputProps}
className={`${prefixCls}-input`}
Expand All @@ -102,8 +101,7 @@ export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
type={type}
/>
<span className={`${prefixCls}-inner`} />
{children !== undefined && <span>{children}</span>}
</label>
</span>
);
});

Expand Down
16 changes: 8 additions & 8 deletions tests/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rc-checkbox click checkbox 1`] = `
<label
<span
class="rc-checkbox"
>
<input
Expand All @@ -11,11 +11,11 @@ exports[`rc-checkbox click checkbox 1`] = `
<span
class="rc-checkbox-inner"
/>
</label>
</span>
`;

exports[`rc-checkbox click radio 1`] = `
<label
<span
class="rc-checkbox rc-checkbox-checked"
>
<input
Expand All @@ -25,11 +25,11 @@ exports[`rc-checkbox click radio 1`] = `
<span
class="rc-checkbox-inner"
/>
</label>
</span>
`;

exports[`rc-checkbox control mode 1`] = `
<label
<span
class="rc-checkbox rc-checkbox-checked"
>
<input
Expand All @@ -40,11 +40,11 @@ exports[`rc-checkbox control mode 1`] = `
<span
class="rc-checkbox-inner"
/>
</label>
</span>
`;

exports[`rc-checkbox works 1`] = `
<label
<span
class="rc-checkbox"
>
<input
Expand All @@ -54,5 +54,5 @@ exports[`rc-checkbox works 1`] = `
<span
class="rc-checkbox-inner"
/>
</label>
</span>
`;