Move the stoppage to somewhere more generic

pull/21833/head
Travis Ralston 2020-07-02 15:15:33 -06:00
parent 547690374e
commit 3847dc91c0
2 changed files with 10 additions and 11 deletions

View File

@ -140,6 +140,13 @@ export class ContextMenu extends React.Component {
e.stopPropagation(); e.stopPropagation();
}; };
// Prevent clicks on the background from going through to the component which opened the menu.
_onFinished = (ev: InputEvent) => {
ev.stopPropagation();
ev.preventDefault();
if (this.props.onFinished) this.props.onFinished();
};
_onMoveFocus = (element, up) => { _onMoveFocus = (element, up) => {
let descending = false; // are we currently descending or ascending through the DOM tree? let descending = false; // are we currently descending or ascending through the DOM tree?
@ -326,7 +333,7 @@ export class ContextMenu extends React.Component {
let background; let background;
if (hasBackground) { if (hasBackground) {
background = ( background = (
<div className="mx_ContextualMenu_background" style={wrapperStyle} onClick={props.onFinished} onContextMenu={this.onContextMenu} /> <div className="mx_ContextualMenu_background" style={wrapperStyle} onClick={this._onFinished} onContextMenu={this.onContextMenu} />
); );
} }

View File

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