Skip to content

Conversation

jcjp
Copy link
Contributor

@jcjp jcjp commented Sep 6, 2025

Description

  • Fixes: #21972
  • Check the model value if it's an empty string and treat it as a not dirty value
  • In this way we could show the placeholder from props

Markup:

<template>
  <v-app>
    <v-container>
      <v-combobox
        v-model="d"
        placeholder="placeholder"
        persistent-placeholder
        :items="['a','b','c']"
      />
    </v-container>
  </v-app>
</template>

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

  const d = ref('')
</script>

@jcjp jcjp requested a review from a team September 6, 2025 15:32
@jcjp jcjp self-assigned this Sep 6, 2025
@jcjp jcjp added T: bug Functionality that does not work as intended/expected C: VCombobox labels Sep 6, 2025
@jcjp jcjp marked this pull request as ready for review September 6, 2025 15:34
@@ -477,7 +477,8 @@ export const VCombobox = genericComponent<new <
slots['append-item'] ||
slots['no-data']
)
const isDirty = model.value.length > 0
const isEmptyString = model.value.length === 1 && model.value[0].value === ''
Copy link
Contributor

Choose a reason for hiding this comment

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

It should rather be named isArrayWithEmptyString. Regardless... I don't think a combobox with multiple and model-value="['']" can be considered empty. It behaves differently when selecting more values. Showing placeholder in this case could be misleading.

Copy link
Contributor Author

@jcjp jcjp Sep 7, 2025

Choose a reason for hiding this comment

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

Oh okay gotcha, so this should be regarded as intended. I am a bit confused since the model.value is coming out as array of objects.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd just put !props.multiple there

Copy link
Contributor

@J-Sek J-Sek Sep 12, 2025

Choose a reason for hiding this comment

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

Upon reading comment, it might make sense to resolve '' into empty array. I had an attempt on it in the past, but the scope might had been too broad (so #20742 got stuck).

@KaelWD KaelWD force-pushed the master branch 4 times, most recently from 142b234 to bb54746 Compare September 12, 2025 09:01
@jcjp jcjp marked this pull request as draft September 12, 2025 10:15
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.6] v-combobox placeholder not showing initially if the model value is empty string
2 participants