Skip to content

Commit

Permalink
fix(Toggle): make onClick optional in TypeScript interface (#14226)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrugger authored Jul 17, 2023
1 parent fc4ee8c commit 77157e2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/react/src/components/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ export interface ToggleProps
/**
* Specify the label for the "off" position
*/
labelA?: string | undefined;
labelA?: string;

/**
* Specify the label for the "on" position
*/
labelB?: string | undefined;
labelB?: string;

/**
* Provide the text that will be read by a screen reader when visiting this
* control. This should be provided unless 'aria-labelledby' is set instead
* or you use an external <label> element with its "for" attribute set to the
* toggle's id.
*/
labelText?: string | undefined;
labelText?: string;

/**
* If true, the side labels (props.labelA and props.labelB) will be replaced by
Expand All @@ -63,10 +63,9 @@ export interface ToggleProps
/**
* Provide an event listener that is called when the control is toggled
*/
onClick:
onClick?:
| MouseEventHandler<HTMLDivElement>
| KeyboardEventHandler<HTMLDivElement>
| undefined;
| KeyboardEventHandler<HTMLDivElement>;

/**
* Provide an event listener that is called when the control is toggled
Expand All @@ -76,22 +75,22 @@ export interface ToggleProps
/**
* Specify the size of the Toggle. Currently only supports 'sm' or 'md' (default)
*/
size?: 'sm' | 'md' | undefined;
size?: 'sm' | 'md';

/**
* Whether the toggle should be read-only
*/
readOnly?: boolean | undefined;
readOnly?: boolean;

/**
* Specify whether the toggle should be on by default
*/
defaultToggled?: boolean | undefined;
defaultToggled?: boolean;

/**
* Specify whether the control is toggled
*/
toggled?: boolean | undefined;
toggled?: boolean;
}

export function Toggle({
Expand Down

0 comments on commit 77157e2

Please sign in to comment.