Wrap event stoppage in null checks

Some of the code paths (particularly onFinished) do not have events, but the code paths we care about to prevent the room selection do have events - we can stop those without stopping further menus.
This commit is contained in:
Travis Ralston 2020-07-02 14:53:21 -06:00
parent aa702514ce
commit 547690374e

View file

@ -160,9 +160,11 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
this.setState({notificationsMenuPosition: target.getBoundingClientRect()});
};
private onCloseNotificationsMenu = (ev: InputEvent) => {
ev.preventDefault();
ev.stopPropagation();
private onCloseNotificationsMenu = (ev?: InputEvent) => {
if (ev) {
ev.preventDefault();
ev.stopPropagation();
}
this.setState({notificationsMenuPosition: null});
};
@ -187,9 +189,11 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
});
};
private onCloseGeneralMenu = (ev: InputEvent) => {
ev.preventDefault();
ev.stopPropagation();
private onCloseGeneralMenu = (ev?: InputEvent) => {
if (ev) {
ev.preventDefault();
ev.stopPropagation();
}
this.setState({generalMenuPosition: null});
};