fix: Clicking dropdown menu items in FF (#2269)

* fix: Clicking dropdown menu items in FF
closes #2264

* fix: Anchor items, add comment

* fix: CI test memory issues
This commit is contained in:
Tom Moor
2021-07-04 06:54:40 -07:00
committed by GitHub
parent f65469b777
commit 286a15cf10
3 changed files with 15 additions and 12 deletions

View File

@ -26,16 +26,18 @@ const MenuItem = ({
hide,
...rest
}: Props) => {
const handleClick = React.useCallback(
// We bind to mousedown instead of onClick here as otherwise menu items do not
// work in Firefox which triggers the hideOnClickOutside handler first via
// mousedown.
const handleMouseDown = React.useCallback(
(ev) => {
if (onClick) {
ev.preventDefault();
ev.stopPropagation();
onClick(ev);
}
if (hide) {
hide();
}
},
[hide, onClick]
[onClick]
);
return (
@ -50,7 +52,8 @@ const MenuItem = ({
{...props}
$toggleable={selected !== undefined}
as={onClick ? "button" : as}
onClick={handleClick}
onMouseDown={handleMouseDown}
onClick={hide}
>
{selected !== undefined && (
<>