Skip to content

Commit

Permalink
fix: remove focus on unselecting the checkbox
Browse files Browse the repository at this point in the history
affects: @medly-components/core, @medly-components/forms
  • Loading branch information
gmukul01 committed Jul 10, 2024
1 parent b903371 commit a21e9d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/components/Accordion/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type AccordionContextType = [
Dispatch<SetStateAction<boolean>> /** Function to be called to toggle the active state */
];

export type AccordionProps = {
export type AccordionProps = Omit<HTMLProps<HTMLDivElement>, 'onChange'> & {
/** Use to render any component as Button */
as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
/** Set it true to open the accordion by default */
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CheckIcon, MinimizeIcon } from '@medly-components/icons';
import { isValidStringOrNumber, useCombinedRefs, useKeyPress, WithStyle } from '@medly-components/utils';
import { WithStyle, isValidStringOrNumber, useCombinedRefs, useKeyPress } from '@medly-components/utils';
import { ChangeEvent, FC, FocusEvent, forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { SelectorLabel } from '../Selectors';
import * as Styled from './Checkbox.styled';
Expand Down Expand Up @@ -51,7 +51,10 @@ const Component: FC<CheckboxProps> = memo(
[validate, props.onInvalid]
),
onChange = useCallback(
(event: ChangeEvent<HTMLInputElement>) => validate(event, props.onChange, false),
(event: ChangeEvent<HTMLInputElement>) => {
validate(event, props.onChange, false);
!event.target.checked && event.target.blur();
},
[validate, props.onChange]
);

Expand Down

0 comments on commit a21e9d9

Please sign in to comment.