Skip to content

Commit

Permalink
Fix selected checkbox fill color when checkbox group is disabled (#5407)
Browse files Browse the repository at this point in the history
* Fix selected checkbox fill color when checkbox group is disabled

* get isDisable from checkbox group state
  • Loading branch information
yihuiliao committed Nov 13, 2023
1 parent 3bc83a2 commit 3efd6c0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/@react-spectrum/checkbox/src/Checkbox.tsx
Expand Up @@ -32,13 +32,11 @@ function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelEleme
let {
isIndeterminate = false,
isEmphasized = false,
isDisabled = false,
autoFocus,
children,
...otherProps
} = props;
let {styleProps} = useStyleProps(otherProps);
let {hoverProps, isHovered} = useHover({isDisabled});

let inputRef = useRef<HTMLInputElement>(null);
let domRef = useFocusableRef(ref, inputRef);
Expand All @@ -47,7 +45,7 @@ function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelEleme
// This is a bit unorthodox. Typically, hooks cannot be called in a conditional,
// but since the checkbox won't move in and out of a group, it should be safe.
let groupState = useContext(CheckboxGroupContext);
let {inputProps, isInvalid} = groupState
let {inputProps, isInvalid, isDisabled} = groupState
// eslint-disable-next-line react-hooks/rules-of-hooks
? useCheckboxGroupItem({
...props,
Expand All @@ -64,6 +62,8 @@ function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelEleme
// eslint-disable-next-line react-hooks/rules-of-hooks
: useCheckbox(props, useToggleState(props), inputRef);

let {hoverProps, isHovered} = useHover({isDisabled});

let markIcon = isIndeterminate
? <DashSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-partialCheckmark')} />
: <CheckmarkSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-checkmark')} />;
Expand Down

1 comment on commit 3efd6c0

@rspbot
Copy link

@rspbot rspbot commented on 3efd6c0 Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.