[Backport staging] Fix usages of useContextMenu which never pass the ref to the element (#9450)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>pull/28788/head^2
parent
450ddbe2b0
commit
8fa1c2bf2a
|
@ -83,7 +83,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
|
||||||
getRelationsForEvent,
|
getRelationsForEvent,
|
||||||
}) => {
|
}) => {
|
||||||
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
|
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
|
||||||
const [onFocus, isActive, ref] = useRovingTabIndex(button);
|
const [onFocus, isActive] = useRovingTabIndex(button);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onFocusChange(menuDisplayed);
|
onFocusChange(menuDisplayed);
|
||||||
}, [onFocusChange, menuDisplayed]);
|
}, [onFocusChange, menuDisplayed]);
|
||||||
|
@ -123,7 +123,7 @@ const OptionsButton: React.FC<IOptionsButtonProps> = ({
|
||||||
onClick={onOptionsClick}
|
onClick={onOptionsClick}
|
||||||
onContextMenu={onOptionsClick}
|
onContextMenu={onOptionsClick}
|
||||||
isExpanded={menuDisplayed}
|
isExpanded={menuDisplayed}
|
||||||
inputRef={ref}
|
inputRef={button}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
tabIndex={isActive ? 0 : -1}
|
tabIndex={isActive ? 0 : -1}
|
||||||
>
|
>
|
||||||
|
@ -141,7 +141,7 @@ interface IReactButtonProps {
|
||||||
|
|
||||||
const ReactButton: React.FC<IReactButtonProps> = ({ mxEvent, reactions, onFocusChange }) => {
|
const ReactButton: React.FC<IReactButtonProps> = ({ mxEvent, reactions, onFocusChange }) => {
|
||||||
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
|
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu();
|
||||||
const [onFocus, isActive, ref] = useRovingTabIndex(button);
|
const [onFocus, isActive] = useRovingTabIndex(button);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onFocusChange(menuDisplayed);
|
onFocusChange(menuDisplayed);
|
||||||
}, [onFocusChange, menuDisplayed]);
|
}, [onFocusChange, menuDisplayed]);
|
||||||
|
@ -173,7 +173,7 @@ const ReactButton: React.FC<IReactButtonProps> = ({ mxEvent, reactions, onFocusC
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onContextMenu={onClick}
|
onContextMenu={onClick}
|
||||||
isExpanded={menuDisplayed}
|
isExpanded={menuDisplayed}
|
||||||
inputRef={ref}
|
inputRef={button}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
tabIndex={isActive ? 0 : -1}
|
tabIndex={isActive ? 0 : -1}
|
||||||
>
|
>
|
||||||
|
|
|
@ -179,6 +179,7 @@ const EmojiButton: React.FC<IEmojiButtonProps> = ({ addEmoji, menuPosition }) =>
|
||||||
iconClassName="mx_MessageComposer_emoji"
|
iconClassName="mx_MessageComposer_emoji"
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
title={_t("Emoji")}
|
title={_t("Emoji")}
|
||||||
|
inputRef={button}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{ contextMenu }
|
{ contextMenu }
|
||||||
|
|
Loading…
Reference in New Issue