Skip to content

Commit

Permalink
fix: extend RadioButtonProps and CheckBoxProps to OcBaseProps (#143)
Browse files Browse the repository at this point in the history
* fix: extend RadioButtonProps and CheckBoxProps to OcBaseProps

* fix: add null check to onRadioButtonClick call

Co-authored-by: yash <yash@MacBook-Pro-Yash-Kelkar-RQMM9RC70H.local>
  • Loading branch information
ykelkar-eightfold and yash authored May 25, 2022
1 parent 1b74497 commit e8a0280
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Selectors/RadioButton/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const RadioButton: FC<RadioButtonProps> = ({
value={value}
onClick={(e) => {
updateActiveRadioButton(value);
onRadioButtonClick(value, e);
onRadioButtonClick?.(value, e);
}}
readOnly
/>
Expand Down
6 changes: 4 additions & 2 deletions src/components/Selectors/Selectors.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { OcBaseProps } from '../OcBase';

export type SelectRadioButtonEvent<E = HTMLElement> =
| React.MouseEvent<E>
Expand All @@ -22,7 +23,7 @@ export interface IRadioButtonsContext {
onRadioButtonClick: OnChangeHandler;
}

export interface CheckBoxProps {
export interface CheckBoxProps extends OcBaseProps<HTMLInputElement> {
/**
* Allows focus on the checkbox when it's disabled.
*/
Expand Down Expand Up @@ -70,7 +71,8 @@ export interface CheckBoxProps {
onChange?: React.ChangeEventHandler<HTMLInputElement>;
}

export interface RadioButtonProps {
export interface RadioButtonProps
extends Omit<OcBaseProps<HTMLElement>, 'onChange'> {
/**
* The default radio button to select
*/
Expand Down

0 comments on commit e8a0280

Please sign in to comment.