Skip to content

Commit

Permalink
not to propagate the data attributes to inputProps
Browse files Browse the repository at this point in the history
  • Loading branch information
syd03098 committed Oct 10, 2024
1 parent cbe43e6 commit 5422253
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/react-aria-components/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function Checkbox(props: CheckboxProps, ref: ForwardedRef<HTMLLabelElement>) {
let {labelProps, inputProps, isSelected, isDisabled, isReadOnly, isPressed, isInvalid} = groupState
// eslint-disable-next-line react-hooks/rules-of-hooks
? useCheckboxGroupItem({
...props,
...removeDataAttributes(props),
// Value is optional for standalone checkboxes, but required for CheckboxGroup items;
// it's passed explicitly here to avoid typescript error (requires ignore).
// @ts-ignore
Expand All @@ -190,7 +190,7 @@ function Checkbox(props: CheckboxProps, ref: ForwardedRef<HTMLLabelElement>) {
}, groupState, inputRef)
// eslint-disable-next-line react-hooks/rules-of-hooks
: useCheckbox({
...props,
...removeDataAttributes(props),
children: typeof props.children === 'function' ? true : props.children,
validationBehavior
// eslint-disable-next-line react-hooks/rules-of-hooks
Expand Down Expand Up @@ -239,10 +239,7 @@ function Checkbox(props: CheckboxProps, ref: ForwardedRef<HTMLLabelElement>) {
data-invalid={isInvalid || undefined}
data-required={props.isRequired || undefined}>
<VisuallyHidden elementType="span">
<input
// data attribute should only go to the outermost dom
{...mergeProps(removeDataAttributes(inputProps), focusProps)}
ref={inputRef} />
<input {...mergeProps(inputProps, focusProps)} ref={inputRef} />
</VisuallyHidden>
{renderProps.children}
</label>
Expand Down

0 comments on commit 5422253

Please sign in to comment.