diff --git a/components/lib/checkbox/Checkbox.js b/components/lib/checkbox/Checkbox.js index be08e01422..6889e80dc0 100644 --- a/components/lib/checkbox/Checkbox.js +++ b/components/lib/checkbox/Checkbox.js @@ -12,8 +12,12 @@ export const Checkbox = React.memo( const mergeProps = useMergeProps(); const context = React.useContext(PrimeReactContext); const props = CheckboxBase.getProps(inProps, context); + const [focusedState, setFocusedState] = React.useState(false); const { ptm, cx, isUnstyled } = CheckboxBase.setMetaData({ props, + state: { + focused: focusedState + }, context: { checked: props.checked === props.trueValue, disabled: props.disabled @@ -68,10 +72,12 @@ export const Checkbox = React.memo( }; const onFocus = () => { + setFocusedState(true); props?.onFocus?.(); }; const onBlur = () => { + setFocusedState(false); props?.onBlur?.(); }; diff --git a/components/lib/checkbox/checkbox.d.ts b/components/lib/checkbox/checkbox.d.ts index 19706c887a..fab8626738 100644 --- a/components/lib/checkbox/checkbox.d.ts +++ b/components/lib/checkbox/checkbox.d.ts @@ -23,6 +23,7 @@ export declare type CheckboxPassThroughType = PassThroughType