From e8a0280b17bdb6f56552014342770e006c6d5aa5 Mon Sep 17 00:00:00 2001 From: ykelkar-eightfold <102243974+ykelkar-eightfold@users.noreply.github.com> Date: Tue, 24 May 2022 18:18:18 -0700 Subject: [PATCH] fix: extend RadioButtonProps and CheckBoxProps to OcBaseProps (#143) * fix: extend RadioButtonProps and CheckBoxProps to OcBaseProps * fix: add null check to onRadioButtonClick call Co-authored-by: yash --- src/components/Selectors/RadioButton/RadioButton.tsx | 2 +- src/components/Selectors/Selectors.types.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Selectors/RadioButton/RadioButton.tsx b/src/components/Selectors/RadioButton/RadioButton.tsx index c3b59952c..98aa28044 100644 --- a/src/components/Selectors/RadioButton/RadioButton.tsx +++ b/src/components/Selectors/RadioButton/RadioButton.tsx @@ -44,7 +44,7 @@ export const RadioButton: FC = ({ value={value} onClick={(e) => { updateActiveRadioButton(value); - onRadioButtonClick(value, e); + onRadioButtonClick?.(value, e); }} readOnly /> diff --git a/src/components/Selectors/Selectors.types.ts b/src/components/Selectors/Selectors.types.ts index bfc6f79d4..e1b6ece17 100644 --- a/src/components/Selectors/Selectors.types.ts +++ b/src/components/Selectors/Selectors.types.ts @@ -1,4 +1,5 @@ import React from 'react'; +import { OcBaseProps } from '../OcBase'; export type SelectRadioButtonEvent = | React.MouseEvent @@ -22,7 +23,7 @@ export interface IRadioButtonsContext { onRadioButtonClick: OnChangeHandler; } -export interface CheckBoxProps { +export interface CheckBoxProps extends OcBaseProps { /** * Allows focus on the checkbox when it's disabled. */ @@ -70,7 +71,8 @@ export interface CheckBoxProps { onChange?: React.ChangeEventHandler; } -export interface RadioButtonProps { +export interface RadioButtonProps + extends Omit, 'onChange'> { /** * The default radio button to select */