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