Skip to content

Commit 1288be7

Browse files
committed
chore(menu): Fixed MenuBar visibility for touch devices
1 parent 3597d32 commit 1288be7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/menu/src/useMenu.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import {
77
} from "react";
88
import { FABPosition } from "@react-md/button";
99
import { useFixedPositioning } from "@react-md/transition";
10-
import { containsElement, useScrollLock } from "@react-md/utils";
10+
import {
11+
containsElement,
12+
useIsUserInteractionMode,
13+
useScrollLock,
14+
} from "@react-md/utils";
1115

1216
import { useMenuBarContext } from "./MenuBarProvider";
1317
import type {
@@ -196,6 +200,7 @@ export function useMenu<ToggleEl extends HTMLElement>(
196200
} = options;
197201
const { menubar, activeId, setActiveId, hoverTimeout, setAnimatedOnce } =
198202
useMenuBarContext();
203+
const touch = useIsUserInteractionMode("touch");
199204

200205
const timeout = useRef<number | undefined>();
201206
useEffect(() => {
@@ -423,7 +428,13 @@ export function useMenu<ToggleEl extends HTMLElement>(
423428
},
424429
onMouseEnter(event) {
425430
onToggleMouseEnter(event);
426-
if (event.isPropagationStopped() || disabled || !menubar || !activeId) {
431+
if (
432+
event.isPropagationStopped() ||
433+
disabled ||
434+
!menubar ||
435+
!activeId ||
436+
touch
437+
) {
427438
if (typeof hoverTimeout === "number") {
428439
timeout.current = window.setTimeout(() => {
429440
setActiveId(baseId);

0 commit comments

Comments
 (0)