primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
10.29k stars 1.22k forks source link

Select: throws an error with auto-filter-focus #6539

Open Tamas-hi opened 2 weeks ago

Tamas-hi commented 2 weeks ago

Describe the bug

From v 4.10, the Select component throws an error when you click out of the dropdown, when auto-filter-focus is enabled.

<PrimeVueSelect v-model="customer" checkmark show-clear filter auto-filter-focus // this throws an error scroll-height="20rem" option-label="company_code" :options="customerOptions" :loading="customerOptionsLoading" :disabled="customerOptionsLoading" class="w-full" :invalid="Boolean(errors.customer)" v-bind="customerAttrs"

image

Reproducer

-

PrimeVue version

4.10

Vue version

4.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

wijzijnweb commented 2 weeks ago

The pull request from @KumJungMin is for opening the select. This is about closing it.

https://github.com/primefaces/primevue/pull/6546

1Map commented 1 week ago

The following line in your code throws an error as filterInput is null:

focus(this.$refs.filterInput.$el);

primevue/packages/primevue/src/select/Select.vue

I do not think it should try and focus on the filter during onOverlayLeave as the filterInput is not always there (null)

intelmib commented 1 week ago

primevue/pacotes/primevue/src/select/Select.vue

a comment there is to be resolved on line 693

this.autoFilterFocus && focus(this.$refs.filterInput.$el);

1Map commented 1 week ago

The following should be completely removed from onOverlayLeave as there is no need to focus on the filterInput Element during Leave.

            if (this.autoFilterFocus && this.filter) {
                this.$nextTick(() => {
                    focus(this.$refs.filterInput.$el);
                });
            }

It is only needed in onOverlayEnter

wijzijnweb commented 23 hours ago

Thought the same @1Map. Created a pull-request https://github.com/primefaces/primevue/pull/6546 but they considered fixing the focus feature. But in my opinion as well there seems no need to focus onLeave since the input isn't shown anyways. Better to focus the document instead, but I don't think it matters.

We'll see how it will be fixed.