Skip to content

The open alternative to Salesforce, designed for AI.

Fix command menu selectable items ordering (#10392)

Raphaël Bosi7a3e92fe0b7b
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx
index a5ac88220c0..2e03852c5db 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx
@@ -36,18 +36,6 @@ export const CommandMenu = () => {
commandMenuSearch,
});
- const selectableItems: Command[] = copilotCommands
- .concat(
- matchingStandardActionRecordSelectionCommands,
- matchingStandardActionObjectCommands,
- matchingWorkflowRunRecordSelectionCommands,
- matchingStandardActionGlobalCommands,
- matchingWorkflowRunGlobalCommands,
- matchingNavigateCommands,
- fallbackCommands,
- )
- .filter(isDefined);
-
const previousContextStoreCurrentObjectMetadataItem =
useRecoilComponentValueV2(
contextStoreCurrentObjectMetadataItemComponentState,
@@ -58,12 +46,6 @@ export const CommandMenu = () => {
contextStoreCurrentObjectMetadataItemComponentState,
);
- const selectableItemIds = selectableItems.map((item) => item.id);
-
- if (isDefined(previousContextStoreCurrentObjectMetadataItem)) {
- selectableItemIds.unshift(RESET_CONTEXT_TO_SELECTION);
- }
-
const commandGroups: CommandGroupConfig[] = [
{
heading: t`Copilot`,
@@ -91,6 +73,16 @@ export const CommandMenu = () => {
},
];
+ const selectableItems: Command[] = commandGroups.flatMap(
+ (group) => group.items ?? [],
+ );
+
+ const selectableItemIds = selectableItems.map((item) => item.id);
+
+ if (isDefined(previousContextStoreCurrentObjectMetadataItem)) {
+ selectableItemIds.unshift(RESET_CONTEXT_TO_SELECTION);
+ }
+
return (
<CommandMenuList
commandGroups={commandGroups}