mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-19 22:34:15 +00:00
Show default node list after clearing search input (#6231)
 Resolves #4887 <details> <summary>The dirty details</summary> There's really not a cleaner workaround here. Prime vue is hardcoded to hide results when a query is received with length 0. With our search box, we never want completions not to be shown and the sanest, if not the only viable solution, is to simply block the hiding completely. Future TODO: - Completely remove the reFocusInput jank. If we can make the search box a frame more responsive, we should. ```ts onInput(event) { if (this.typeahead) { if (this.searchTimeout) { clearTimeout(this.searchTimeout); } let query = event.target.value; if (!this.multiple) { this.updateModel(event, query); } if (query.length === 0) { this.hide(); this.$emit('clear'); } else { if (query.length >= this.minLength) { this.focusedOptionIndex = -1; this.searchTimeout = setTimeout(() => { this.search(event, query, 'input'); }, this.delay); } else { this.hide(); } } } } hide(isFocus) { const _hide = () => { this.$emit('before-hide'); this.dirty = isFocus; this.overlayVisible = false; this.clicked = false; this.focusedOptionIndex = -1; isFocus && focus(this.multiple ? this.$refs.focusInput : this.$refs.focusInput?.$el); }; setTimeout(() => { _hide(); }, 0); // For ScreenReaders } ``` </details> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6231-Show-default-node-list-after-clearing-search-input-2956d73d36508134960df537c7409646) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
</Dialog>
|
||||
|
||||
<AutoCompletePlus
|
||||
ref="autoCompletePlus"
|
||||
:model-value="filters"
|
||||
class="comfy-vue-node-search-box z-10 grow"
|
||||
scroll-height="40vh"
|
||||
@@ -42,7 +43,6 @@
|
||||
:input-id="inputId"
|
||||
append-to="self"
|
||||
:suggestions="suggestions"
|
||||
:min-length="0"
|
||||
:delay="100"
|
||||
:loading="!nodeFrequencyStore.isLoaded"
|
||||
complete-on-focus
|
||||
@@ -106,6 +106,7 @@ const { filters, searchLimit = 64 } = defineProps<{
|
||||
searchLimit?: number
|
||||
}>()
|
||||
|
||||
const autoCompletePlus = ref()
|
||||
const nodeSearchFilterVisible = ref(false)
|
||||
const inputId = `comfy-vue-node-search-box-input-${Math.random()}`
|
||||
const suggestions = ref<ComfyNodeDefImpl[]>([])
|
||||
@@ -140,7 +141,13 @@ const reFocusInput = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(reFocusInput)
|
||||
onMounted(() => {
|
||||
inputElement ??= document.getElementById(inputId) as HTMLInputElement
|
||||
if (inputElement) inputElement.focus()
|
||||
autoCompletePlus.value.hide = () => search('')
|
||||
search('')
|
||||
autoCompletePlus.value.show()
|
||||
})
|
||||
const onAddFilter = (
|
||||
filterAndValue: FuseFilterWithValue<ComfyNodeDefImpl, string>
|
||||
) => {
|
||||
|
||||
Reference in New Issue
Block a user