From 3b9ca2263de1b936639b1b20ad0baf1cb059fda5 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Mon, 9 Dec 2024 10:17:54 +0100 Subject: [PATCH] fix(CommandPalette): keep `ignoreFilter` groups at their place (#2833) --- src/runtime/components/CommandPalette.vue | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/runtime/components/CommandPalette.vue b/src/runtime/components/CommandPalette.vue index 2f0c7a85fb..5e3520dc92 100644 --- a/src/runtime/components/CommandPalette.vue +++ b/src/runtime/components/CommandPalette.vue @@ -220,14 +220,15 @@ const groups = computed(() => { return getGroupWithItems(group, items) }).filter(group => !!group) - const nonFuseGroups = props.groups?.filter(group => group.ignoreFilter && group.items?.length).map((group) => { - return getGroupWithItems(group, group.items || []) - }) || [] - - return [ - ...fuseGroups, - ...nonFuseGroups - ] + const nonFuseGroups = props.groups + ?.map((group, index) => ({ ...group, index })) + ?.filter(group => group.ignoreFilter && group.items?.length) + ?.map(group => ({ ...getGroupWithItems(group, group.items || []), index: group.index })) || [] + + return nonFuseGroups.reduce((acc, group) => { + acc.splice(group.index, 0, group) + return acc + }, [...fuseGroups]) })