diff --git a/src/runtime/components/navigation/CommandPalette.vue b/src/runtime/components/navigation/CommandPalette.vue index dc1f5c0d..6f57ca53 100644 --- a/src/runtime/components/navigation/CommandPalette.vue +++ b/src/runtime/components/navigation/CommandPalette.vue @@ -61,15 +61,7 @@ const props = defineProps({ }, options: { type: Object as PropType>, - default: () => ({ - fuseOptions: { - keys: ['label'], - isCaseSensitive: false, - threshold: undefined - }, - resultLimit: 12, - matchAllWhenSearchEmpty: true - }) + default: () => ({}) } }) @@ -86,13 +78,23 @@ onMounted(() => { const commands = computed(() => props.groups.flatMap(group => group.commands.map(command => ({ ...command, group: group.key })))) -const { results } = useFuse(query, commands, props.options) +const options = computed(() => Object.assign({}, { + fuseOptions: { + keys: ['label'], + isCaseSensitive: false, + threshold: undefined + }, + resultLimit: 12, + matchAllWhenSearchEmpty: true +}, props.options)) + +const { results } = useFuse(query, commands, options) const groupedResults = computed(() => { return props.groups.map(group => ({ key: group.key, label: group.label, - commands: results.value.map(result => result.item).filter(item => item.group === group.key) + commands: results.value.map(result => result.item).filter(item => item.group === group.key).slice(0, props.options.resultLimit) })).filter(group => group.commands.length) })