Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Fix: Remove duplicate separators in action menus (#8509)

Daizuc2d34aaabe13
diff --git a/frontend/src/components/editor/cell/cell-actions.tsx b/frontend/src/components/editor/cell/cell-actions.tsx
index 0757a2e7b4..ca0d56cf6b 100644
--- a/frontend/src/components/editor/cell/cell-actions.tsx
+++ b/frontend/src/components/editor/cell/cell-actions.tsx
@@ -64,6 +64,10 @@ const CellActionsDropdownInternal = (
const buttonRef = useRef<HTMLButtonElement>(null);
const actions = useCellActionButtons({ cell: props, closePopover });
+ const visibleActions = actions
+ .map((group) => group.filter((action) => !action.redundant))
+ .filter((group) => group.length > 0);
+
// store the last focused element so we can restore it when the popover closes
const restoreFocus = useRestoreFocus();
@@ -112,13 +116,10 @@ const CellActionsDropdownInternal = (
/>
<CommandList>
<CommandEmpty>No results</CommandEmpty>
- {actions.map((group, i) => (
+ {visibleActions.map((group, i) => (
<Fragment key={i}>
<CommandGroup key={i}>
{group.map((action) => {
- if (action.redundant) {
- return null;
- }
let body = (
<div className="flex items-center flex-1">
{action.icon && (
@@ -162,7 +163,7 @@ const CellActionsDropdownInternal = (
);
})}
</CommandGroup>
- {i < actions.length - 1 && <CommandSeparator />}
+ {i < visibleActions.length - 1 && <CommandSeparator />}
</Fragment>
))}
</CommandList>
diff --git a/frontend/src/components/editor/cell/cell-context-menu.tsx b/frontend/src/components/editor/cell/cell-context-menu.tsx
index c78a341b00..d37333b837 100644
--- a/frontend/src/components/editor/cell/cell-context-menu.tsx
+++ b/frontend/src/components/editor/cell/cell-context-menu.tsx
@@ -176,6 +176,12 @@ export const CellActionsContextMenu = ({
const allActions: ActionButton[][] = [DEFAULT_CONTEXT_MENU_ITEMS, ...actions];
+ const visibleActions = allActions
+ .map((group) =>
+ group.filter((action) => !action.hidden && !action.redundant),
+ )
+ .filter((group) => group.length > 0);
+
return (
<ContextMenu>
<ContextMenuTrigger
@@ -191,13 +197,9 @@ export const CellActionsContextMenu = ({
{children}
</ContextMenuTrigger>
<ContextMenuContent className="w-[300px]" scrollable={true}>
- {allActions.map((group, i) => (
+ {visibleActions.map((group, i) => (
<Fragment key={i}>
{group.map((action) => {
- if (action.hidden || action.redundant) {
- return null;
- }
-
let body = (
<div className="flex items-center flex-1">
{action.icon && (
@@ -258,7 +260,7 @@ export const CellActionsContextMenu = ({
</Fragment>
);
})}
- {i < allActions.length - 1 && <ContextMenuSeparator />}
+ {i < visibleActions.length - 1 && <ContextMenuSeparator />}
</Fragment>
))}
</ContextMenuContent>