Fix error on close of combo dropdown (#7804)

Apparently, enabling autofocus causes primevue to also attempt focusing
the searchbox one frame after closing.

I have no idea why this behaviour would ever be beneficial, but this PR
adds an override to prevent this behaviour and clean up the console
spam.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7804-Fix-error-on-close-of-combo-dropdown-2d96d73d365081f8b677e3e4aaadb51b)
by [Unito](https://www.unito.io)

---------

Co-authored-by: Alexander Brown <drjkl@comfy.org>
This commit is contained in:
AustinMroz
2026-01-13 15:31:55 -08:00
committed by GitHub
parent 97a78f4a35
commit 20d06f92ca
3 changed files with 31 additions and 13 deletions

View File

@@ -0,0 +1,19 @@
<script>
import Select from 'primevue/select'
export default {
name: 'SelectPlus',
extends: Select,
emits: ['hide'],
methods: {
onOverlayLeave() {
this.unbindOutsideClickListener()
this.unbindScrollListener()
this.unbindResizeListener()
this.$emit('hide')
this.overlay = null
}
}
}
</script>

View File

@@ -1,13 +1,12 @@
import { createTestingPinia } from '@pinia/testing' import { createTestingPinia } from '@pinia/testing'
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import PrimeVue from 'primevue/config' import PrimeVue from 'primevue/config'
import Select from 'primevue/select'
import type { SelectProps } from 'primevue/select' import type { SelectProps } from 'primevue/select'
import { beforeEach, describe, expect, it, vi } from 'vitest' import { beforeEach, describe, expect, it, vi } from 'vitest'
import SelectPlus from '@/components/primevueOverride/SelectPlus.vue'
import type { ComboInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' import type { ComboInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
import type { SimplifiedWidget } from '@/types/simplifiedWidget' import type { SimplifiedWidget } from '@/types/simplifiedWidget'
import WidgetSelect from '@/renderer/extensions/vueNodes/widgets/components/WidgetSelect.vue' import WidgetSelect from '@/renderer/extensions/vueNodes/widgets/components/WidgetSelect.vue'
import WidgetSelectDefault from '@/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue' import WidgetSelectDefault from '@/renderer/extensions/vueNodes/widgets/components/WidgetSelectDefault.vue'
import WidgetSelectDropdown from '@/renderer/extensions/vueNodes/widgets/components/WidgetSelectDropdown.vue' import WidgetSelectDropdown from '@/renderer/extensions/vueNodes/widgets/components/WidgetSelectDropdown.vue'
@@ -76,7 +75,7 @@ describe('WidgetSelect Value Binding', () => {
}, },
global: { global: {
plugins: [PrimeVue, createTestingPinia()], plugins: [PrimeVue, createTestingPinia()],
components: { Select } components: { SelectPlus }
} }
}) })
} }
@@ -85,7 +84,7 @@ describe('WidgetSelect Value Binding', () => {
wrapper: ReturnType<typeof mount>, wrapper: ReturnType<typeof mount>,
value: string value: string
) => { ) => {
const select = wrapper.findComponent({ name: 'Select' }) const select = wrapper.findComponent({ name: 'SelectPlus' })
await select.setValue(value) await select.setValue(value)
return wrapper.emitted('update:modelValue') return wrapper.emitted('update:modelValue')
} }
@@ -150,7 +149,7 @@ describe('WidgetSelect Value Binding', () => {
const widget = createMockWidget('', { values: [] }) const widget = createMockWidget('', { values: [] })
const wrapper = mountComponent(widget, '') const wrapper = mountComponent(widget, '')
const select = wrapper.findComponent({ name: 'Select' }) const select = wrapper.findComponent({ name: 'SelectPlus' })
expect(select.props('options')).toEqual([]) expect(select.props('options')).toEqual([])
}) })
@@ -160,7 +159,7 @@ describe('WidgetSelect Value Binding', () => {
}) })
const wrapper = mountComponent(widget, 'only_option') const wrapper = mountComponent(widget, 'only_option')
const select = wrapper.findComponent({ name: 'Select' }) const select = wrapper.findComponent({ name: 'SelectPlus' })
const options = select.props('options') const options = select.props('options')
expect(options).toHaveLength(1) expect(options).toHaveLength(1)
expect(options[0]).toEqual('only_option') expect(options[0]).toEqual('only_option')
@@ -228,7 +227,7 @@ describe('WidgetSelect Value Binding', () => {
}, },
global: { global: {
plugins: [PrimeVue, createTestingPinia()], plugins: [PrimeVue, createTestingPinia()],
components: { Select } components: { SelectPlus }
} }
}) })
@@ -247,7 +246,7 @@ describe('WidgetSelect Value Binding', () => {
}, },
global: { global: {
plugins: [PrimeVue, createTestingPinia()], plugins: [PrimeVue, createTestingPinia()],
components: { Select } components: { SelectPlus }
} }
}) })
@@ -271,7 +270,7 @@ describe('WidgetSelect Value Binding', () => {
}, },
global: { global: {
plugins: [PrimeVue, createTestingPinia()], plugins: [PrimeVue, createTestingPinia()],
components: { Select } components: { SelectPlus }
} }
}) })
@@ -290,7 +289,7 @@ describe('WidgetSelect Value Binding', () => {
}, },
global: { global: {
plugins: [PrimeVue, createTestingPinia()], plugins: [PrimeVue, createTestingPinia()],
components: { Select } components: { SelectPlus }
} }
}) })

View File

@@ -1,10 +1,10 @@
<template> <template>
<WidgetLayoutField :widget> <WidgetLayoutField :widget>
<Select <SelectPlus
v-model="modelValue" v-model="modelValue"
:invalid :invalid
:filter="selectOptions.length > 4" :filter="selectOptions.length > 4"
:auto-filter-focus="selectOptions.length > 4" auto-filter-focus
:options="selectOptions" :options="selectOptions"
v-bind="combinedProps" v-bind="combinedProps"
:class="cn(WidgetInputBaseClass, 'w-full text-xs')" :class="cn(WidgetInputBaseClass, 'w-full text-xs')"
@@ -25,9 +25,9 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Select from 'primevue/select'
import { computed } from 'vue' import { computed } from 'vue'
import SelectPlus from '@/components/primevueOverride/SelectPlus.vue'
import { useTransformCompatOverlayProps } from '@/composables/useTransformCompatOverlayProps' import { useTransformCompatOverlayProps } from '@/composables/useTransformCompatOverlayProps'
import type { SimplifiedWidget } from '@/types/simplifiedWidget' import type { SimplifiedWidget } from '@/types/simplifiedWidget'
import { cn } from '@/utils/tailwindUtil' import { cn } from '@/utils/tailwindUtil'