diff --git a/components/lib/breadcrumb/BreadCrumb.js b/components/lib/breadcrumb/BreadCrumb.js index d13e5b8b42..bc836c3199 100644 --- a/components/lib/breadcrumb/BreadCrumb.js +++ b/components/lib/breadcrumb/BreadCrumb.js @@ -29,16 +29,17 @@ export const BreadCrumb = React.memo( return; } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, item }); } + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const isCurrent = (url) => { diff --git a/components/lib/contextmenu/ContextMenuSub.js b/components/lib/contextmenu/ContextMenuSub.js index 858450f87b..e0b8bed26e 100644 --- a/components/lib/contextmenu/ContextMenuSub.js +++ b/components/lib/contextmenu/ContextMenuSub.js @@ -43,10 +43,6 @@ export const ContextMenuSub = React.memo( return; } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, @@ -59,6 +55,11 @@ export const ContextMenuSub = React.memo( if (!item.items) { props.onLeafClick(event); } + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const position = () => { diff --git a/components/lib/megamenu/MegaMenu.js b/components/lib/megamenu/MegaMenu.js index b6409d524b..fa823eee67 100644 --- a/components/lib/megamenu/MegaMenu.js +++ b/components/lib/megamenu/MegaMenu.js @@ -160,16 +160,16 @@ export const MegaMenu = React.memo( return; } - if (!item.url) { - originalEvent.preventDefault(); - } - if (item.command) { item.command({ originalEvent: originalEvent, item: props.item }); + } + + if (!item.url) { originalEvent.preventDefault(); + originalEvent.stopPropagation(); } const grouped = isProccessedItemGroup(processedItem); diff --git a/components/lib/menubar/MenubarSub.js b/components/lib/menubar/MenubarSub.js index 87a12a0a51..0799802d38 100644 --- a/components/lib/menubar/MenubarSub.js +++ b/components/lib/menubar/MenubarSub.js @@ -44,10 +44,6 @@ export const MenubarSub = React.memo( return; } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, @@ -56,6 +52,11 @@ export const MenubarSub = React.memo( } onLeafClick({ originalEvent: event, processedItem, isFocus: true }); + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const onLeafClick = (event) => { diff --git a/components/lib/panelmenu/PanelMenu.js b/components/lib/panelmenu/PanelMenu.js index 1a4eb154c3..b761f49e80 100644 --- a/components/lib/panelmenu/PanelMenu.js +++ b/components/lib/panelmenu/PanelMenu.js @@ -38,10 +38,6 @@ export const PanelMenu = React.memo( return; } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, @@ -52,6 +48,11 @@ export const PanelMenu = React.memo( if (item.items) { changeActiveItem(event, item); } + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const getItemProp = (item, name) => { diff --git a/components/lib/slidemenu/SlideMenuSub.js b/components/lib/slidemenu/SlideMenuSub.js index 5aa722edcf..56050a1cf0 100644 --- a/components/lib/slidemenu/SlideMenuSub.js +++ b/components/lib/slidemenu/SlideMenuSub.js @@ -25,10 +25,6 @@ export const SlideMenuSub = React.memo((props) => { return; } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, @@ -43,6 +39,11 @@ export const SlideMenuSub = React.memo((props) => { setActiveItemState(item); props.onForward(); } + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const createSeparator = (index) => { diff --git a/components/lib/steps/Steps.js b/components/lib/steps/Steps.js index 5900a9baf9..f5dc862a1f 100644 --- a/components/lib/steps/Steps.js +++ b/components/lib/steps/Steps.js @@ -39,10 +39,6 @@ export const Steps = React.memo( }); } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, @@ -50,6 +46,11 @@ export const Steps = React.memo( index }); } + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const onItemKeyDown = (event, item, index) => { diff --git a/components/lib/tabmenu/TabMenu.js b/components/lib/tabmenu/TabMenu.js index 5b53168195..f90c9e1fe4 100644 --- a/components/lib/tabmenu/TabMenu.js +++ b/components/lib/tabmenu/TabMenu.js @@ -50,10 +50,6 @@ export const TabMenu = React.memo( return; } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, @@ -70,6 +66,11 @@ export const TabMenu = React.memo( } else { setActiveIndexState(index); } + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const isSelected = (index) => { diff --git a/components/lib/tieredmenu/TieredMenuSub.js b/components/lib/tieredmenu/TieredMenuSub.js index a7345669d4..e553659b3c 100644 --- a/components/lib/tieredmenu/TieredMenuSub.js +++ b/components/lib/tieredmenu/TieredMenuSub.js @@ -49,10 +49,6 @@ export const TieredMenuSub = React.memo( return; } - if (!item.url) { - event.preventDefault(); - } - if (item.command) { item.command({ originalEvent: event, @@ -61,6 +57,11 @@ export const TieredMenuSub = React.memo( } props.onItemClick && props.onItemClick({ originalEvent: event, processedItem }); + + if (!item.url) { + event.preventDefault(); + event.stopPropagation(); + } }; const getItemId = (processedItem) => {