Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VAutocomplete/VCombobox): avoid input absolute position when having selection slot #19294

Merged
merged 8 commits into from
Mar 1, 2024

Conversation

yuwu9145
Copy link
Member

@yuwu9145 yuwu9145 commented Feb 28, 2024

fixes #17573

Improve experience in #17291

Description

When having chip or selection shot:

  • Input shouldn't be absolute positioned
  • Search value (input) should always be empty when unfocused
  • I will do comprehensive testing, but extra eyes on testing always welcome

Markup:

<template>
  <v-app>
    <v-container>
      <h1>Single selection</h1>
      <h2>Autocomplete</h2>
      <v-autocomplete
        :items="items"
        item-title="name"
        item-value="age"
        label="no selection slot"
        @update:search="updateSearch"
      />
      <v-autocomplete
        :items="items"
        item-title="name"
        item-value="age"
        label="selection slot"
        @update:search="updateSearch"
      >
        <template #selection="{ item }">
          <VChip>{{ item.raw.name }} - {{ item.raw.age }}</VChip>
        </template>
        <template #item="{ item, props }">
          <v-list-item v-bind="props" title="">
            {{ item.raw.name }} - {{ item.raw.age }}
          </v-list-item>
        </template>
      </v-autocomplete>

      <v-autocomplete
        :items="items"
        item-title="name"
        item-value="age"
        label="chips"
        chips
      >
        <template #item="{ item, props }">
          <v-list-item v-bind="props" title="">
            {{ item.raw.name }} - {{ item.raw.age }}
          </v-list-item>
        </template>
      </v-autocomplete>

      <h2>Combobox</h2>
      <v-combobox
        label="no selection slot"
        :modelValue="'California'"
        @update:search="updateSearch"
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
      />
      <v-combobox
        label="selection slot"
        @update:search="updateSearch"
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
      >
        <template #selection="{ item }">
          <VChip>{{ item.title }}</VChip>
        </template>
      </v-combobox>
      <v-combobox
        chips
        label="chips"
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
      />
      <h1>Multiple selection</h1>
      <h2>Autocomplete</h2>
      <v-autocomplete
        :items="items"
        item-title="name"
        item-value="age"
        multiple 
        label="no selection slot"
      />
      <v-autocomplete
        :items="items"
        item-title="name"
        item-value="age"
        multiple 
        label="selection slot"
      >
        <template #selection="{ item }">
          <VChip>{{ item.raw.name }} - {{ item.raw.age }}</VChip>
        </template>
        <template #item="{ item, props }">
          <v-list-item v-bind="props" title="">
            {{ item.raw.name }} - {{ item.raw.age }}
          </v-list-item>
        </template>
      </v-autocomplete>

      <v-autocomplete
        :items="items"
        item-title="name"
        item-value="age"
        label="chips"
        multiple 
        chips
      >
        <template #item="{ item, props }">
          <v-list-item v-bind="props" title="">
            {{ item.raw.name }} - {{ item.raw.age }}
          </v-list-item>
        </template>
      </v-autocomplete>

      <h2>Combobox</h2>
      <v-combobox
        label="no selection slot"
        multiple
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
      />
      <v-combobox
        label="selection slot"
        multiple
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
      >
        <template #selection="{ item }">
          <VChip>{{ item.title }}</VChip>
        </template>
      </v-combobox>
      <v-combobox
        chips
        multiple
        label="chips"
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
      />
    </v-container>
  </v-app>
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  const items = [
    {
      name: 'first',
      age: 42,
    },
    {
      name: 'second',
      age: 83,
    },
  ]
  function updateSearch(search) {
    console.log('--updateSearch-', search)
  }
</script>


@yuwu9145 yuwu9145 marked this pull request as ready for review March 1, 2024 14:15
@yuwu9145 yuwu9145 requested review from johnleider and KaelWD March 1, 2024 14:16
@johnleider johnleider added T: bug Functionality that does not work as intended/expected C: VCombobox VCombobox C: VAutocomplete VAutocomplete labels Mar 1, 2024
@johnleider johnleider added this to the v3.5.x milestone Mar 1, 2024
@johnleider johnleider merged commit 1e57453 into master Mar 1, 2024
17 of 18 checks passed
@johnleider johnleider deleted the fix-17573 branch March 1, 2024 18:20
VIXI0 pushed a commit to VIXI0/vuetify that referenced this pull request Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VAutocomplete VAutocomplete C: VCombobox 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.3.2] v-autocomplete selection slot not shown while control has focus
2 participants