Skip to content

Commit

Permalink
chore(menu): Fixed MenuBar visibility for touch devices
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Jan 31, 2022
1 parent 3597d32 commit 1288be7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/menu/src/useMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
} from "react";
import { FABPosition } from "@react-md/button";
import { useFixedPositioning } from "@react-md/transition";
import { containsElement, useScrollLock } from "@react-md/utils";
import {
containsElement,
useIsUserInteractionMode,
useScrollLock,
} from "@react-md/utils";

import { useMenuBarContext } from "./MenuBarProvider";
import type {
Expand Down Expand Up @@ -196,6 +200,7 @@ export function useMenu<ToggleEl extends HTMLElement>(
} = options;
const { menubar, activeId, setActiveId, hoverTimeout, setAnimatedOnce } =
useMenuBarContext();
const touch = useIsUserInteractionMode("touch");

const timeout = useRef<number | undefined>();
useEffect(() => {
Expand Down Expand Up @@ -423,7 +428,13 @@ export function useMenu<ToggleEl extends HTMLElement>(
},
onMouseEnter(event) {
onToggleMouseEnter(event);
if (event.isPropagationStopped() || disabled || !menubar || !activeId) {
if (
event.isPropagationStopped() ||
disabled ||
!menubar ||
!activeId ||
touch
) {
if (typeof hoverTimeout === "number") {
timeout.current = window.setTimeout(() => {
setActiveId(baseId);
Expand Down

0 comments on commit 1288be7

Please sign in to comment.