mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
Fix sorting on type filter + empty query (#880)
* Fix sorting on type filter + empty query * nit * nit
This commit is contained in:
@@ -106,15 +106,15 @@ const placeholder = computed(() => {
|
|||||||
const nodeDefStore = useNodeDefStore()
|
const nodeDefStore = useNodeDefStore()
|
||||||
const nodeFrequencyStore = useNodeFrequencyStore()
|
const nodeFrequencyStore = useNodeFrequencyStore()
|
||||||
const search = (query: string) => {
|
const search = (query: string) => {
|
||||||
|
const queryIsEmpty = query === '' && props.filters.length === 0
|
||||||
currentQuery.value = query
|
currentQuery.value = query
|
||||||
suggestions.value =
|
suggestions.value = queryIsEmpty
|
||||||
query === ''
|
? nodeFrequencyStore.topNodeDefs
|
||||||
? nodeFrequencyStore.topNodeDefs
|
: [
|
||||||
: [
|
...nodeDefStore.nodeSearchService.searchNode(query, props.filters, {
|
||||||
...nodeDefStore.nodeSearchService.searchNode(query, props.filters, {
|
limit: props.searchLimit
|
||||||
limit: props.searchLimit
|
})
|
||||||
})
|
]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const emit = defineEmits(['addFilter', 'removeFilter', 'addNode'])
|
const emit = defineEmits(['addFilter', 'removeFilter', 'addNode'])
|
||||||
|
|||||||
@@ -32,11 +32,10 @@ export class FuseSearch<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public search(query: string, options?: FuseSearchOptions): T[] {
|
public search(query: string, options?: FuseSearchOptions): T[] {
|
||||||
if (!query || query === '') {
|
const fuseResult = !query
|
||||||
return [...this.data]
|
? this.data.map((x) => ({ item: x, score: 0 }))
|
||||||
}
|
: this.fuse.search(query, options)
|
||||||
|
|
||||||
const fuseResult = this.fuse.search(query, options)
|
|
||||||
if (!this.advancedScoring) {
|
if (!this.advancedScoring) {
|
||||||
return fuseResult.map((x) => x.item)
|
return fuseResult.map((x) => x.item)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,11 @@ const EXAMPLE_NODE_DEFS: ComfyNodeDefImpl[] = [
|
|||||||
category: 'latent/batch',
|
category: 'latent/batch',
|
||||||
output_node: false
|
output_node: false
|
||||||
}
|
}
|
||||||
].map((nodeDef) => plainToClass(ComfyNodeDefImpl, nodeDef))
|
].map((nodeDef) => {
|
||||||
|
const def = plainToClass(ComfyNodeDefImpl, nodeDef)
|
||||||
|
def['postProcessSearchScores'] = (s) => s
|
||||||
|
return def
|
||||||
|
})
|
||||||
|
|
||||||
describe('nodeSearchService', () => {
|
describe('nodeSearchService', () => {
|
||||||
it('searches with input filter', () => {
|
it('searches with input filter', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user