From a1df87a37579ff948302a1387e2ec160409c9dea Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 19 Dec 2019 07:23:05 +0000 Subject: [PATCH] Make EmojiPicker an unmanaged Context Menu as it is too complex to be managed --- src/components/structures/ContextMenu.js | 20 +++++++++++-------- .../views/messages/MessageActionBar.js | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/structures/ContextMenu.js b/src/components/structures/ContextMenu.js index e861e3d45f..662972ee37 100644 --- a/src/components/structures/ContextMenu.js +++ b/src/components/structures/ContextMenu.js @@ -71,12 +71,12 @@ export class ContextMenu extends React.Component { // on resize callback windowResize: PropTypes.func, - catchTab: PropTypes.bool, // whether to close the ContextMenu on TAB (default=true) + managed: PropTypes.bool, // whether this context menu should be focus managed. If false it must handle itself }; static defaultProps = { hasBackground: true, - catchTab: true, + managed: true, }; constructor() { @@ -186,15 +186,19 @@ export class ContextMenu extends React.Component { }; _onKeyDown = (ev) => { + if (!this.props.managed) { + if (ev.key === Key.ESCAPE) { + this.props.onFinished(); + ev.stopPropagation(); + ev.preventDefault(); + } + return; + } + let handled = true; switch (ev.key) { case Key.TAB: - if (!this.props.catchTab) { - handled = false; - break; - } - // fallthrough case Key.ESCAPE: this.props.onFinished(); break; @@ -321,7 +325,7 @@ export class ContextMenu extends React.Component { return (
-
+
{ chevron } { props.children }
diff --git a/src/components/views/messages/MessageActionBar.js b/src/components/views/messages/MessageActionBar.js index 81e806cf62..52d7a74632 100644 --- a/src/components/views/messages/MessageActionBar.js +++ b/src/components/views/messages/MessageActionBar.js @@ -88,7 +88,7 @@ const ReactButton = ({mxEvent, reactions, onFocusChange}) => { if (menuDisplayed) { const buttonRect = button.current.getBoundingClientRect(); const ReactionPicker = sdk.getComponent('emojipicker.ReactionPicker'); - contextMenu = + contextMenu = ; }