Skip to content

Commit

Permalink
feat(CommandPalette): handle static groups (#1458)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Canac <[email protected]>
  • Loading branch information
maximepvrt and benjamincanac authored Jul 23, 2024
1 parent f374b14 commit b264ad2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/runtime/components/navigation/CommandPalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default defineComponent({
const commands = computed(() => {
const commands: Command[] = []
for (const group of props.groups) {
if (!group.search) {
if (!group.search && !group.static) {
commands.push(...(group.commands?.map(command => ({ ...command, group: group.key })) || []))
}
}
Expand Down Expand Up @@ -274,9 +274,14 @@ export default defineComponent({
return getGroupWithCommands(group, [...commands])
})
const staticGroups: Group[] = props.groups.filter((group) => group.static && group.commands?.length).map((group) => {
return getGroupWithCommands(group, group.commands)
})
return [
...groups,
...searchGroups
...searchGroups,
...staticGroups
]
})
Expand Down
1 change: 1 addition & 0 deletions src/runtime/types/command-palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ export interface Group {
commands?: Command[]
search?: Function
filter?: Function
static?: Boolean
[key: string]: any
}

0 comments on commit b264ad2

Please sign in to comment.