Skip to content

Commit

Permalink
feat: make onDismiss optional on Menu (#3417)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewalczak authored Oct 18, 2022
1 parent ef448b1 commit 5700fe5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type Props = {
/**
* Callback called when Menu is dismissed. The `visible` prop needs to be updated when this is called.
*/
onDismiss: () => void;
onDismiss?: () => void;
/**
* Accessibility label for the overlay. This is read by the screen reader when the user taps outside the menu.
*/
Expand Down Expand Up @@ -234,14 +234,14 @@ class Menu extends React.Component<Props, State> {

private handleDismiss = () => {
if (this.props.visible) {
this.props.onDismiss();
this.props.onDismiss?.();
}
return true;
};

private handleKeypress = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
this.props.onDismiss();
this.props.onDismiss?.();
}
};

Expand Down

0 comments on commit 5700fe5

Please sign in to comment.