1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-10 09:22:25 +03:00

Don't open the regular browser or our context menu on right-clicking the Options button in the message action bar (#8648)

This commit is contained in:
Šimon Brandner
2022-05-19 17:26:35 +02:00
committed by GitHub
parent 395b167b20
commit efc36acf93

View File

@@ -76,6 +76,17 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
onFocusChange(menuDisplayed);
}, [onFocusChange, menuDisplayed]);
const onOptionsClick = (e: React.MouseEvent): void => {
// Don't open the regular browser or our context menu on right-click
e.preventDefault();
e.stopPropagation();
openMenu();
// when the context menu is opened directly, e.g. via mouse click, the onFocus handler which tracks
// the element that is currently focused is skipped. So we want to call onFocus manually to keep the
// position in the page even when someone is clicking around.
onFocus();
};
let contextMenu: ReactElement | null;
if (menuDisplayed) {
const tile = getTile && getTile();
@@ -97,13 +108,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
<ContextMenuTooltipButton
className="mx_MessageActionBar_maskButton mx_MessageActionBar_optionsButton"
title={_t("Options")}
onClick={() => {
openMenu();
// when the context menu is opened directly, e.g. via mouse click, the onFocus handler which tracks
// the element that is currently focused is skipped. So we want to call onFocus manually to keep the
// position in the page even when someone is clicking around.
onFocus();
}}
onClick={onOptionsClick}
isExpanded={menuDisplayed}
inputRef={ref}
onFocus={onFocus}