Skip to content

Commit

Permalink
Revert "feat: improve a11y (#292)" (#293)
Browse files Browse the repository at this point in the history
This reverts commit d3de52f.
  • Loading branch information
aojunhao123 authored Nov 20, 2024
1 parent 9e147ab commit 014079e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
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>
`;

0 comments on commit 014079e

Please sign in to comment.