From 029d950a766ff632e7cc872e603cab6144ef374b Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 8 Nov 2022 07:55:27 -0500 Subject: [PATCH] Fix #3590: TieredMenu hide on leaf click --- components/lib/tieredmenu/TieredMenu.js | 10 ++++++---- components/lib/tieredmenu/TieredMenuSub.js | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/lib/tieredmenu/TieredMenu.js b/components/lib/tieredmenu/TieredMenu.js index 777ba8be79..aab358399c 100644 --- a/components/lib/tieredmenu/TieredMenu.js +++ b/components/lib/tieredmenu/TieredMenu.js @@ -44,9 +44,11 @@ export const TieredMenu = React.memo( }; const hide = (event) => { - targetRef.current = event.currentTarget; - setVisibleState(false); - props.onHide && props.onHide(event); + if (props.popup) { + targetRef.current = event.currentTarget; + setVisibleState(false); + props.onHide && props.onHide(event); + } }; const onEnter = () => { @@ -106,7 +108,7 @@ export const TieredMenu = React.memo( onExited={onExited} >
- +
); diff --git a/components/lib/tieredmenu/TieredMenuSub.js b/components/lib/tieredmenu/TieredMenuSub.js index 499b60078f..fe5db70a20 100644 --- a/components/lib/tieredmenu/TieredMenuSub.js +++ b/components/lib/tieredmenu/TieredMenuSub.js @@ -72,7 +72,7 @@ export const TieredMenuSub = React.memo((props) => { } if (!item.items) { - onLeafClick(); + onLeafClick(event); } }; @@ -136,9 +136,10 @@ export const TieredMenuSub = React.memo((props) => { return prevItem ? (DomHandler.hasClass(prevItem, 'p-disabled') || !DomHandler.hasClass(prevItem, 'p-menuitem') ? findPrevItem(prevItem) : prevItem) : null; }; - const onLeafClick = () => { + const onLeafClick = (event) => { setActiveItemState(null); - props.onLeafClick && props.onLeafClick(); + props.onLeafClick && props.onLeafClick(event); + props.onHide && props.onHide(event); }; useMountEffect(() => {