Fix command menu selectable items ordering (#10392)
The order of the selectableItems was not the same as the command groups so the navigation with arrow keys inside the command menu was broken. Before: https://github.com/user-attachments/assets/a3487b58-9c26-4522-9e7b-584d30396a21 After: https://github.com/user-attachments/assets/bd60263b-b4e2-4d41-bad1-eef9115caec6
This commit is contained in:
@ -36,18 +36,6 @@ export const CommandMenu = () => {
|
|||||||
commandMenuSearch,
|
commandMenuSearch,
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectableItems: Command[] = copilotCommands
|
|
||||||
.concat(
|
|
||||||
matchingStandardActionRecordSelectionCommands,
|
|
||||||
matchingStandardActionObjectCommands,
|
|
||||||
matchingWorkflowRunRecordSelectionCommands,
|
|
||||||
matchingStandardActionGlobalCommands,
|
|
||||||
matchingWorkflowRunGlobalCommands,
|
|
||||||
matchingNavigateCommands,
|
|
||||||
fallbackCommands,
|
|
||||||
)
|
|
||||||
.filter(isDefined);
|
|
||||||
|
|
||||||
const previousContextStoreCurrentObjectMetadataItem =
|
const previousContextStoreCurrentObjectMetadataItem =
|
||||||
useRecoilComponentValueV2(
|
useRecoilComponentValueV2(
|
||||||
contextStoreCurrentObjectMetadataItemComponentState,
|
contextStoreCurrentObjectMetadataItemComponentState,
|
||||||
@ -58,12 +46,6 @@ export const CommandMenu = () => {
|
|||||||
contextStoreCurrentObjectMetadataItemComponentState,
|
contextStoreCurrentObjectMetadataItemComponentState,
|
||||||
);
|
);
|
||||||
|
|
||||||
const selectableItemIds = selectableItems.map((item) => item.id);
|
|
||||||
|
|
||||||
if (isDefined(previousContextStoreCurrentObjectMetadataItem)) {
|
|
||||||
selectableItemIds.unshift(RESET_CONTEXT_TO_SELECTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
const commandGroups: CommandGroupConfig[] = [
|
const commandGroups: CommandGroupConfig[] = [
|
||||||
{
|
{
|
||||||
heading: t`Copilot`,
|
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 (
|
return (
|
||||||
<CommandMenuList
|
<CommandMenuList
|
||||||
commandGroups={commandGroups}
|
commandGroups={commandGroups}
|
||||||
|
|||||||
Reference in New Issue
Block a user