From a280a577816e4b862b8b09f1523277a783f5a32b Mon Sep 17 00:00:00 2001 From: Melloware Date: Fri, 27 Sep 2024 08:40:54 -0400 Subject: [PATCH] Fix #7261: Menu separator respect visible property (#7263) --- components/lib/contextmenu/ContextMenuSub.js | 4 ++++ components/lib/menu/Menu.js | 8 ++++---- components/lib/menubar/MenubarSub.js | 4 ++++ components/lib/panelmenu/PanelMenuSub.js | 4 ++++ components/lib/slidemenu/SlideMenuSub.js | 4 ++++ components/lib/tieredmenu/TieredMenuSub.js | 4 ++++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/components/lib/contextmenu/ContextMenuSub.js b/components/lib/contextmenu/ContextMenuSub.js index 9e37a0a4da..4e3ba66a73 100644 --- a/components/lib/contextmenu/ContextMenuSub.js +++ b/components/lib/contextmenu/ContextMenuSub.js @@ -293,6 +293,10 @@ export const ContextMenuSub = React.memo( }; const createItem = (processedItem, index) => { + if (processedItem.visible === false) { + return null; + } + return processedItem.separator ? createSeparator(index) : createMenuItem(processedItem, index); }; diff --git a/components/lib/menu/Menu.js b/components/lib/menu/Menu.js index 8ea00da93d..cc5111e166 100644 --- a/components/lib/menu/Menu.js +++ b/components/lib/menu/Menu.js @@ -335,10 +335,6 @@ export const Menu = React.memo( }; const createMenuItem = (item, index, parentId = null) => { - if (item.visible === false) { - return null; - } - const menuContext = { item, index, parentId }; const linkClassName = classNames('p-menuitem-link', { 'p-disabled': item.disabled }); const iconClassName = classNames('p-menuitem-icon', item.icon); @@ -427,6 +423,10 @@ export const Menu = React.memo( }; const createItem = (item, index) => { + if (item.visible === false) { + return null; + } + return item.separator ? createSeparator(item, index) : item.items ? createSubmenu(item, index) : createMenuItem(item, index); }; diff --git a/components/lib/menubar/MenubarSub.js b/components/lib/menubar/MenubarSub.js index ee688427e8..df86f1ee29 100644 --- a/components/lib/menubar/MenubarSub.js +++ b/components/lib/menubar/MenubarSub.js @@ -265,6 +265,10 @@ export const MenubarSub = React.memo( }; const createItem = (processedItem, index) => { + if (processedItem.visible === false) { + return null; + } + return getItemProp(processedItem, 'separator') ? createSeparator(processedItem, index) : createMenuitem(processedItem, index); }; diff --git a/components/lib/panelmenu/PanelMenuSub.js b/components/lib/panelmenu/PanelMenuSub.js index 7360cf44ae..3a85c42ae7 100644 --- a/components/lib/panelmenu/PanelMenuSub.js +++ b/components/lib/panelmenu/PanelMenuSub.js @@ -258,6 +258,10 @@ export const PanelMenuSub = React.memo( }; const createItem = (item, index) => { + if (item.visible === false) { + return null; + } + return getItemProp(item, 'separator') ? createSeparator(index) : createMenuItem(item, index); }; diff --git a/components/lib/slidemenu/SlideMenuSub.js b/components/lib/slidemenu/SlideMenuSub.js index 3058479e23..7468f8d034 100644 --- a/components/lib/slidemenu/SlideMenuSub.js +++ b/components/lib/slidemenu/SlideMenuSub.js @@ -174,6 +174,10 @@ export const SlideMenuSub = React.memo((props) => { }; const createItem = (item, index) => { + if (item.visible === false) { + return null; + } + return item.separator ? createSeparator(index) : createMenuitem(item, index); }; diff --git a/components/lib/tieredmenu/TieredMenuSub.js b/components/lib/tieredmenu/TieredMenuSub.js index 84658cb0fe..3149a8c7ba 100644 --- a/components/lib/tieredmenu/TieredMenuSub.js +++ b/components/lib/tieredmenu/TieredMenuSub.js @@ -273,6 +273,10 @@ export const TieredMenuSub = React.memo( }; const createItem = (processedItem, index) => { + if (processedItem.visible === false) { + return null; + } + return getItemProp(processedItem, 'separator') ? createSeparator(index) : createMenuItem(processedItem, index); };