Skip to content

Commit 3efd6c0

Browse files
authored
Fix selected checkbox fill color when checkbox group is disabled (#5407)
* Fix selected checkbox fill color when checkbox group is disabled * get isDisable from checkbox group state
1 parent 3bc83a2 commit 3efd6c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/@react-spectrum/checkbox/src/Checkbox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@ function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelEleme
3232
let {
3333
isIndeterminate = false,
3434
isEmphasized = false,
35-
isDisabled = false,
3635
autoFocus,
3736
children,
3837
...otherProps
3938
} = props;
4039
let {styleProps} = useStyleProps(otherProps);
41-
let {hoverProps, isHovered} = useHover({isDisabled});
4240

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

65+
let {hoverProps, isHovered} = useHover({isDisabled});
66+
6767
let markIcon = isIndeterminate
6868
? <DashSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-partialCheckmark')} />
6969
: <CheckmarkSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-checkmark')} />;

0 commit comments

Comments
 (0)