Skip to content

Conversation

@jcjp
Copy link
Contributor

@jcjp jcjp commented Aug 9, 2025

Description

  • Not automatically filtered on load even if search value has value

fixes: #21900

Markup:

<template>
  <v-app>
    <v-container>
      <v-combobox
        v-model="msg"
        :items="['Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming', 'California']"
      />
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref } from 'vue'

  const msg = ref('Cali')
</script>

@jcjp jcjp self-assigned this Aug 9, 2025
@jcjp jcjp requested review from a team and J-Sek August 9, 2025 16:25
J-Sek
J-Sek previously requested changes Aug 11, 2025
Copy link
Contributor

@J-Sek J-Sek left a comment

Choose a reason for hiding this comment

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

When placed side-by-side with VSelect and VAutocomplete, new behavior feels a bit off. - before: I can type 44 (no match) but still re-open full list

  • after: list does not appear and it might feel unexpected/broken

demo

The original problem is the difference between typing the value and setting it programmatically. It would be best to target this specifically and leave the rest as-is.

@J-Sek
Copy link
Contributor

J-Sek commented Aug 11, 2025

Alternative fix:

watch(model, value => {
  if (!props.multiple && !hasSelectionSlot.value) {
-    +search.value = value[0]?.title ?? ''
+    search.value = value[0]?.title ?? ''
  }
-})
+}, { immediate: true })

Breaks some tests... I don't have time to dig it this week. @jcjp, can you evaluate it?

@jcjp jcjp force-pushed the fix(VCombobox#21900)/initial-value-ignored-on-immediate-filter branch from 519849d to 0a54e33 Compare August 17, 2025 12:22
@jcjp
Copy link
Contributor Author

jcjp commented Aug 17, 2025

Alternative fix:

watch(model, value => {
  if (!props.multiple && !hasSelectionSlot.value) {
-    +search.value = value[0]?.title ?? ''
+    search.value = value[0]?.title ?? ''
  }
-})
+}, { immediate: true })

Breaks some tests... I don't have time to dig it this week. @jcjp, can you evaluate it?

I updated the solution, we are running into test issues whenever we try to update the search.value directly on the watch so instead I just emit an update:search for the new value do you think about this, is it okay? I updated my sample code above to use your example on your demo link.

No errors on the test as well, here is the result of the unit test.

VCombobox run vitest VCombobox

image

Full run run vitest

image

@jcjp jcjp requested a review from J-Sek August 17, 2025 12:22
@J-Sek
Copy link
Contributor

J-Sek commented Aug 19, 2025

emit(.. does not break the tests, but also does not seem to have the desired effect - i.e. does not filter the list.

Anyway, my suggestion has the same problem as the previous attempt. Menu does not appear when there is no match (e.g. for msg = ref("xx")) which is inconsistent with typing those letters manually. We need to dig deeper.

@MajesticPotatoe MajesticPotatoe added T: bug Functionality that does not work as intended/expected C: VCombobox labels Aug 22, 2025
@jcjp
Copy link
Contributor Author

jcjp commented Aug 23, 2025

emit(.. does not break the tests, but also does not seem to have the desired effect - i.e. does not filter the list.

Anyway, my suggestion has the same problem as the previous attempt. Menu does not appear when there is no match (e.g. for msg = ref("xx")) which is inconsistent with typing those letters manually. We need to dig deeper.

I recorded my test, I want to clarify if is this not the desired behavior? EDIT: You are right as per my checking will dig deeper thanks Jacek!

@jcjp jcjp dismissed J-Sek’s stale review August 23, 2025 15:09

I have updated my solution, it seems that the target behavior that we need to replicate is already living in VAutocomplete. Let me know if this works, I also run the test and it passes.

@jcjp jcjp force-pushed the fix(VCombobox#21900)/initial-value-ignored-on-immediate-filter branch from 341f40b to a16a917 Compare August 23, 2025 15:41
@jcjp jcjp force-pushed the fix(VCombobox#21900)/initial-value-ignored-on-immediate-filter branch from a16a917 to 22d181f Compare August 23, 2025 16:11
@J-Sek
Copy link
Contributor

J-Sek commented Aug 23, 2025

@jcjp, I have added a test against regression (re-opening menu after typing cal shows all options) and a second one for the new behavior we'd like to observe. Currently, both fail because re-opening does not preserve narrowed options.

Initially, I wrote those tests to be based on keyboard interactions (Tab » type » Escape » ArrowDown), but it looks like the options are only preserved if the user clicks outside... Clicking on the menu icon, Tab, Escape - all other methods of closing - seem to clear the "search". With your changes, click-outside + reopen aligns with all of the other methods, but I don't think it is a desired behavior... It is a tough battle. If you can make these new tests pass, we could merge it and handle the re-opening inconsistency later. Ideally, it should not matter if the user opens the menu for the first or n-th time with any of the methods.

@jcjp jcjp force-pushed the fix(VCombobox#21900)/initial-value-ignored-on-immediate-filter branch from b456bce to 4d98b07 Compare August 23, 2025 17:00
@jcjp
Copy link
Contributor Author

jcjp commented Aug 23, 2025

@jcjp, I have added a test against regression (re-opening menu after typing cal shows all options) and a second one for the new behavior we'd like to observe. Currently, both fail because re-opening does not preserve narrowed options.

Initially, I wrote those tests to be based on keyboard interactions (Tab » type » Escape » ArrowDown), but it looks like the options are only preserved if the user clicks outside... Clicking on the menu icon, Tab, Escape - all other methods of closing - seem to clear the "search". With your changes, click-outside + reopen aligns with all of the other methods, but I don't think it is a desired behavior... It is a tough battle. If you can make these new tests pass, we could merge it and handle the re-opening inconsistency later. Ideally, it should not matter if the user opens the menu for the first or n-th time with any of the methods.

I updated the solution and looks the issue is fixed, thanks for reviewing and adding the test.

J-Sek
J-Sek previously requested changes Aug 23, 2025
@J-Sek
Copy link
Contributor

J-Sek commented Aug 23, 2025

Overall, it looks great. Just anticipating a bug report below.

Recording
Screencast.from.2025-08-23.19-58-20.webm

@johnleider
Copy link
Member

Overall, it looks great. Just anticipating a bug report below.

Recording
Screencast.from.2025-08-23.19-58-20.webm

Recording won't load for me.

@J-Sek
Copy link
Contributor

J-Sek commented Aug 26, 2025

@johnleider, when the text does not match any of the list options, every 2nd time I open the menu it either shows all options or a "No data available". So I am clicking menu icon to toggle it on/off and it consistently cycles between both of these results.

Screenshots image image

It would be great if we could avoid it.

@johnleider
Copy link
Member

The video is loading for me now, thank you.

@jcjp jcjp marked this pull request as draft August 31, 2025 08:43
@jcjp jcjp marked this pull request as draft August 31, 2025 08:43
@jcjp jcjp marked this pull request as ready for review August 31, 2025 15:20
@jcjp jcjp requested a review from J-Sek August 31, 2025 15:20
@jcjp jcjp dismissed J-Sek’s stale review August 31, 2025 15:30

I fixed the bug but there is a flicker animation happening when we blur the input field, looks annoying let me know if you guys are okay with this.

@J-Sek J-Sek changed the title fix(VCombobox): check if search value is not empty, if yes filter immediately (#21900) fix(VCombobox): filter matching items when opening first time Aug 31, 2025
@J-Sek
Copy link
Contributor

J-Sek commented Aug 31, 2025

  • opening first time with non-matching value should show all options (consistently, not only on subsequent attempts)
  • when I defer loading options (e.g. 2s delay), open, close, wait 2s, open - shows all items, not the matching one

I will attempt a cleanup. There are too many boolean flags scattered all over the place and it is making the whole thing very brittle.

@J-Sek
Copy link
Contributor

J-Sek commented Aug 31, 2025

@jcjp, the last commit has changed quite a lot.
Could you please double-check for any regression?

@jcjp
Copy link
Contributor Author

jcjp commented Sep 6, 2025

@jcjp, the last commit has changed quite a lot. Could you please double-check for any regression?

I did the test manually looks good thank you for your help on the flicker issue!

@jcjp jcjp merged commit eeb9d14 into master Sep 6, 2025
18 checks passed
@jcjp jcjp deleted the fix(VCombobox#21900)/initial-value-ignored-on-immediate-filter branch September 6, 2025 14:23
@jcjp jcjp changed the title fix(VCombobox): filter matching items when opening first time fix(VCombobox): filter matching items when opening first time (#21900) Sep 6, 2025
@KaelWD KaelWD added this to the v3.10.0 milestone Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VCombobox T: bug Functionality that does not work as intended/expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][3.9.4] Setting the initial search value via searchInput on VCombobox does not work

6 participants