mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 17:16:26 +01:00
Blind fix for submenus bug
This commit is contained in:
parent
d64bbb7acb
commit
8bfc9892ed
1 changed files with 16 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { Menu, MenuItem, SubMenu } from '@szhsin/react-menu';
|
import { Menu, MenuItem, SubMenu } from '@szhsin/react-menu';
|
||||||
import { cloneElement } from 'preact';
|
import { cloneElement } from 'preact';
|
||||||
|
import { useRef } from 'preact/hooks';
|
||||||
|
|
||||||
function MenuConfirm({
|
function MenuConfirm({
|
||||||
subMenu = false,
|
subMenu = false,
|
||||||
|
@ -20,8 +21,10 @@ function MenuConfirm({
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
const Parent = subMenu ? SubMenu : Menu;
|
const Parent = subMenu ? SubMenu : Menu;
|
||||||
|
const menuRef = useRef();
|
||||||
return (
|
return (
|
||||||
<Parent
|
<Parent
|
||||||
|
instanceRef={menuRef}
|
||||||
openTrigger="clickOnly"
|
openTrigger="clickOnly"
|
||||||
direction="bottom"
|
direction="bottom"
|
||||||
overflow="auto"
|
overflow="auto"
|
||||||
|
@ -31,6 +34,19 @@ function MenuConfirm({
|
||||||
{...restProps}
|
{...restProps}
|
||||||
menuButton={subMenu ? undefined : children}
|
menuButton={subMenu ? undefined : children}
|
||||||
label={subMenu ? children : undefined}
|
label={subMenu ? children : undefined}
|
||||||
|
// Test fix for bug; submenus not opening on Android
|
||||||
|
itemProps={{
|
||||||
|
onPointerMove: (e) => {
|
||||||
|
if (e.pointerType === 'touch') {
|
||||||
|
menuRef.current?.openMenu?.();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onPointerLeave: (e) => {
|
||||||
|
if (e.pointerType === 'touch') {
|
||||||
|
menuRef.current?.openMenu?.();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<MenuItem className={menuItemClassName} onClick={onClick}>
|
<MenuItem className={menuItemClassName} onClick={onClick}>
|
||||||
{confirmLabel}
|
{confirmLabel}
|
||||||
|
|
Loading…
Reference in a new issue