From 3847dc91c06f8796ddfb2aa97440ccc40cc7b165 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 2 Jul 2020 15:15:33 -0600 Subject: [PATCH] Move the stoppage to somewhere more generic --- src/components/structures/ContextMenu.js | 9 ++++++++- src/components/views/rooms/RoomTile2.tsx | 12 ++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/structures/ContextMenu.js b/src/components/structures/ContextMenu.js index 5ba2662796..e43b0d1431 100644 --- a/src/components/structures/ContextMenu.js +++ b/src/components/structures/ContextMenu.js @@ -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 = ( -
+
); } diff --git a/src/components/views/rooms/RoomTile2.tsx b/src/components/views/rooms/RoomTile2.tsx index 6f686dbac3..1024198560 100644 --- a/src/components/views/rooms/RoomTile2.tsx +++ b/src/components/views/rooms/RoomTile2.tsx @@ -160,11 +160,7 @@ export default class RoomTile2 extends React.Component { 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 { }); }; - private onCloseGeneralMenu = (ev?: InputEvent) => { - if (ev) { - ev.preventDefault(); - ev.stopPropagation(); - } + private onCloseGeneralMenu = () => { this.setState({generalMenuPosition: null}); };