Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit efc36ac

Browse files
Don't open the regular browser or our context menu on right-clicking the Options button in the message action bar (#8648)
1 parent 395b167 commit efc36ac

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/components/views/messages/MessageActionBar.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
7676
onFocusChange(menuDisplayed);
7777
}, [onFocusChange, menuDisplayed]);
7878

79+
const onOptionsClick = (e: React.MouseEvent): void => {
80+
// Don't open the regular browser or our context menu on right-click
81+
e.preventDefault();
82+
e.stopPropagation();
83+
openMenu();
84+
// when the context menu is opened directly, e.g. via mouse click, the onFocus handler which tracks
85+
// the element that is currently focused is skipped. So we want to call onFocus manually to keep the
86+
// position in the page even when someone is clicking around.
87+
onFocus();
88+
};
89+
7990
let contextMenu: ReactElement | null;
8091
if (menuDisplayed) {
8192
const tile = getTile && getTile();
@@ -97,13 +108,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
97108
<ContextMenuTooltipButton
98109
className="mx_MessageActionBar_maskButton mx_MessageActionBar_optionsButton"
99110
title={_t("Options")}
100-
onClick={() => {
101-
openMenu();
102-
// when the context menu is opened directly, e.g. via mouse click, the onFocus handler which tracks
103-
// the element that is currently focused is skipped. So we want to call onFocus manually to keep the
104-
// position in the page even when someone is clicking around.
105-
onFocus();
106-
}}
111+
onClick={onOptionsClick}
107112
isExpanded={menuDisplayed}
108113
inputRef={ref}
109114
onFocus={onFocus}

0 commit comments

Comments
 (0)