Skip to content
Open
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
14 changes: 8 additions & 6 deletions code/core/src/manager/components/sidebar/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ export const useContextMenu = (context: API_HashEntry, links: Link[], api: API)
id: 'copy-story-name',
title: copyText,
icon: <CopyIcon />,
// TODO: bring this back once we want to add shortcuts for this
// right:
// enableShortcuts && shortcutKeys.copyStoryName ? (
// <Shortcut keys={shortcutKeys.copyStoryName} />
// ) : null,
onClick: (e: SyntheticEvent) => {
e.preventDefault();
copy(context.exportName);
Expand Down Expand Up @@ -101,6 +96,7 @@ export const useContextMenu = (context: API_HashEntry, links: Link[], api: API)
},
};
}, []);

/**
* Calculate the providerLinks whenever the user mouses over the container. We use an incrementor,
* instead of a simple boolean to ensure that the links are recalculated
Expand All @@ -124,6 +120,12 @@ export const useContextMenu = (context: API_HashEntry, links: Link[], api: API)
return empty;
}

// Deduplicate context menu links before rendering
const mergedLinks = [...topLinks, ...links];
const uniqueLinks = Array.from(
new Map(mergedLinks.map((item) => [item.id, item])).values()
);

return {
onMouseEnter: handlers.onMouseEnter,
node: shouldRender ? (
Expand All @@ -139,7 +141,7 @@ export const useContextMenu = (context: API_HashEntry, links: Link[], api: API)
setIsOpen(true);
}
}}
tooltip={<LiveContextMenu context={context} links={[...topLinks, ...links]} />}
tooltip={<LiveContextMenu context={context} links={uniqueLinks} />}
>
<FloatingStatusButton type="button" status="status-value:pending">
<EllipsisIcon />
Expand Down