From 8bfc9892edcc52a1361dc31db9198cb224bad8d3 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 29 Aug 2023 15:23:58 +0800 Subject: [PATCH] Blind fix for submenus bug --- src/components/menu-confirm.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/menu-confirm.jsx b/src/components/menu-confirm.jsx index 14e67746..40cd146b 100644 --- a/src/components/menu-confirm.jsx +++ b/src/components/menu-confirm.jsx @@ -1,5 +1,6 @@ import { Menu, MenuItem, SubMenu } from '@szhsin/react-menu'; import { cloneElement } from 'preact'; +import { useRef } from 'preact/hooks'; function MenuConfirm({ subMenu = false, @@ -20,8 +21,10 @@ function MenuConfirm({ return children; } const Parent = subMenu ? SubMenu : Menu; + const menuRef = useRef(); return ( { + if (e.pointerType === 'touch') { + menuRef.current?.openMenu?.(); + } + }, + onPointerLeave: (e) => { + if (e.pointerType === 'touch') { + menuRef.current?.openMenu?.(); + } + }, + }} > {confirmLabel}