Skip to content

Commit

Permalink
chore(CommandPalette): filter not working after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Dec 8, 2023
1 parent cbc2742 commit 4dd92f7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/runtime/components/navigation/CommandPalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</template>

<script lang="ts">
import { ref, computed, watch, toRef, onMounted, defineComponent, toRaw } from 'vue'
import { ref, computed, watch, toRef, onMounted, defineComponent } from 'vue'
import { Combobox as HCombobox, ComboboxInput as HComboboxInput, ComboboxOptions as HComboboxOptions } from '@headlessui/vue'
import type { ComputedRef, PropType, ComponentPublicInstance } from 'vue'
import { useDebounceFn } from '@vueuse/core'
Expand Down Expand Up @@ -232,16 +232,13 @@ export default defineComponent({
return
}
const q = toRaw(query)
let newCommands = [...commands]
if (group.filter && typeof group.filter === 'function') {
newCommands = group.filter(q, newCommands)
commands = group.filter(query.value, commands)
}
return {
...group,
commands: newCommands.slice(0, options.value.resultLimit)
commands: commands.slice(0, options.value.resultLimit)
}
}
Expand All @@ -256,8 +253,8 @@ export default defineComponent({
return acc
}
acc[command.item.group] ||= []
acc[command.item.group].push({ ...item, ...data })
acc[item.group] ||= []
acc[item.group].push({ ...item, ...data })
return acc
}, {})
Expand All @@ -274,7 +271,7 @@ export default defineComponent({
const searchGroups = props.groups.filter(group => !!group.search && searchResults.value[group.key]?.length).map(group => {
const commands = (searchResults.value[group.key] || [])
return getGroupWithCommands(group, commands)
return getGroupWithCommands(group, [...commands])
})
return [
Expand Down

1 comment on commit 4dd92f7

@vercel
Copy link

@vercel vercel bot commented on 4dd92f7 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui.nuxt.com
ui-git-dev-nuxt-js.vercel.app
ui-nuxt-js.vercel.app

Please sign in to comment.