Skip to content

Commit

Permalink
fix(checkbox): remove focus styles when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Oct 25, 2021
1 parent bcf319f commit 73ea70c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/checkbox/src/use-checkbox.ts
Expand Up @@ -11,6 +11,7 @@ import React, {
ChangeEvent,
KeyboardEvent,
useCallback,
useEffect,
useRef,
useState,
} from "react"
Expand Down Expand Up @@ -189,6 +190,12 @@ export function useCheckbox(props: UseCheckboxProps = {}) {
}
}, [isIndeterminate])

useEffect(() => {
if (isDisabled) {
setFocused.off()
}
}, [isDisabled, setFocused])

const trulyDisabled = isDisabled && !isFocusable

const onKeyDown = useCallback(
Expand Down

0 comments on commit 73ea70c

Please sign in to comment.