Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5941: Menus consistent handling of URL and command #5949

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions components/lib/breadcrumb/BreadCrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/contextmenu/ContextMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export const ContextMenuSub = React.memo(
return;
}

if (!item.url) {
event.preventDefault();
}

if (item.command) {
item.command({
originalEvent: event,
Expand All @@ -59,6 +55,11 @@ export const ContextMenuSub = React.memo(
if (!item.items) {
props.onLeafClick(event);
}

if (!item.url) {
event.preventDefault();
event.stopPropagation();
}
};

const position = () => {
Expand Down
8 changes: 4 additions & 4 deletions components/lib/megamenu/MegaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions components/lib/menubar/MenubarSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export const MenubarSub = React.memo(
return;
}

if (!item.url) {
event.preventDefault();
}

if (item.command) {
item.command({
originalEvent: event,
Expand All @@ -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) => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/panelmenu/PanelMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export const PanelMenu = React.memo(
return;
}

if (!item.url) {
event.preventDefault();
}

if (item.command) {
item.command({
originalEvent: event,
Expand All @@ -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) => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/slidemenu/SlideMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export const SlideMenuSub = React.memo((props) => {
return;
}

if (!item.url) {
event.preventDefault();
}

if (item.command) {
item.command({
originalEvent: event,
Expand All @@ -43,6 +39,11 @@ export const SlideMenuSub = React.memo((props) => {
setActiveItemState(item);
props.onForward();
}

if (!item.url) {
event.preventDefault();
event.stopPropagation();
}
};

const createSeparator = (index) => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/steps/Steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ export const Steps = React.memo(
});
}

if (!item.url) {
event.preventDefault();
}

if (item.command) {
item.command({
originalEvent: event,
item,
index
});
}

if (!item.url) {
event.preventDefault();
event.stopPropagation();
}
};

const onItemKeyDown = (event, item, index) => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/tabmenu/TabMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ export const TabMenu = React.memo(
return;
}

if (!item.url) {
event.preventDefault();
}

if (item.command) {
item.command({
originalEvent: event,
Expand All @@ -70,6 +66,11 @@ export const TabMenu = React.memo(
} else {
setActiveIndexState(index);
}

if (!item.url) {
event.preventDefault();
event.stopPropagation();
}
};

const isSelected = (index) => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/tieredmenu/TieredMenuSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ export const TieredMenuSub = React.memo(
return;
}

if (!item.url) {
event.preventDefault();
}

if (item.command) {
item.command({
originalEvent: event,
Expand All @@ -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) => {
Expand Down
Loading