Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import CheckBox from './CheckBox';
export default {
title: 'Inputs/CheckBox',
component: CheckBox,
argTypes: {
is: { table: { disable: true } },
},
} satisfies Meta<typeof CheckBox>;

const Template: StoryFn<typeof CheckBox> = (args) => (
Expand Down
16 changes: 8 additions & 8 deletions packages/fuselage/src/components/CheckBox/CheckBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ const CheckBox = forwardRef<HTMLInputElement, CheckBoxProps>(function CheckBox(
const mergedRef = useMergedRefs(ref, innerRef);

useLayoutEffect(() => {
if (innerRef && innerRef.current && indeterminate !== undefined) {
if (innerRef.current && indeterminate !== undefined) {
innerRef.current.indeterminate = indeterminate;
}
}, [innerRef, indeterminate]);
}, [indeterminate]);

const handleChange = useCallback(
(event: FormEvent<HTMLInputElement>) => {
if (innerRef && innerRef.current && indeterminate !== undefined) {
if (innerRef.current && indeterminate !== undefined) {
innerRef.current.indeterminate = indeterminate;
}
onChange?.call(innerRef.current, event);
},
[innerRef, indeterminate, onChange],
[indeterminate, onChange],
);

return (
<Box is='label' className={className} rcx-check-box>
<Box is={'label' as unknown as React.ElementType} className={className} rcx-check-box>
{labelChildren}
<Box
is='input'
is={'input' as unknown as React.ElementType}
type='checkbox'
rcx-check-box__input
ref={mergedRef}
onChange={handleChange}
{...props}
/>
<Box is='i' rcx-check-box__fake aria-hidden='true' />
<Box is={'i' as unknown as React.ElementType} rcx-check-box__fake aria-hidden='true' />
</Box>
);
});

export default CheckBox;
export default CheckBox;
Loading