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

[Bug Report][3.0.0] v-autocomplete items header / divider not working #15721

Open
ppyl-datBoi opened this issue Sep 1, 2022 · 5 comments
Open
Labels
C: VAutocomplete VAutocomplete C: VCombobox VCombobox C: VSelect VSelect has workaround T: enhancement Functionality that enhances existing features

Comments

@ppyl-datBoi
Copy link

Environment

Vuetify Version: 3.0.0-beta.9
Vue Version: 3.2.38
Browsers: Chrome 104.0.0.0
OS: Windows 10

Steps to reproduce

This feature does not work in your example.

Expected Behavior

v-autocomplete reads the options in the object.
image

Actual Behavior

Just empty space
image

Reproduction Link

https://codepen.io/ppyl-datboi/pen/dyebexE?editors=101

@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected C: VSelect VSelect C: VCombobox VCombobox C: VAutocomplete VAutocomplete and removed S: triage labels Sep 1, 2022
@KaelWD KaelWD added this to the v3.0.x milestone Sep 1, 2022
@nekosaur nekosaur self-assigned this Sep 1, 2022
@johnleider johnleider changed the title [Bug Report][3.0.0-beta.9] Reading "divider" and "header" parameters in objects doesn't work in "v-autocomplete" [Bug Report][3.0.0] v-autocomplete items header / divider not working Nov 30, 2022
@KaelWD KaelWD modified the milestones: v3.0.x, v3.1.x Jan 6, 2023
@ajslater
Copy link

A workaround for this is very easy with item slots. It was a nice little feature of v2 but not critical.
e.g.

    <template #item="{ item, props }">
      <!-- Divider in items not implemented yet in Vuetify 3 -->
      <v-divider v-if="item.value === 'f'" />
      <v-list-item v-bind="props" :title="item.title" :value="item.value" />
    </template>

@johnleider johnleider modified the milestones: v3.1.x, v3.x.x Apr 4, 2023
@KaelWD KaelWD added T: enhancement Functionality that enhances existing features and removed T: bug Functionality that does not work as intended/expected labels May 26, 2023
@grolu
Copy link

grolu commented Jun 12, 2023

If you consider this to be an enhancement and not a bug, it would be nice if you could remove this feature from the documentation...

@ElYaiko
Copy link

ElYaiko commented Jun 17, 2023

Any update? in VSelect items with { header: '' } / { divider: true } is not working neither but is in the documentation

A temporal fix:

                  <template #item="{ item, props }">
                    <VDivider v-if="'divider' in item.raw" />
                    <VListSubheader v-else-if="'header' in item.raw" :title="item.raw.header"/>
                    <VListItem v-else v-bind="props" :title="item.title" :value="item.value"/>
                  </template>

@NightFurySL2001
Copy link

NightFurySL2001 commented Sep 26, 2023

From the documentation:

Can be an array of objects or array of strings. When using objects, will look for a title, value and disabled keys. This can be changed using the item-title, item-value and item-disabled props. Objects that have a header or divider property are considered special cases and generate a list header or divider; these items are not selectable.

Please remove this from the documentation if this is not working anymore.

Also related: #4148 (comment)

header and divider have been moved to type: 'subheader' | 'divider' in v3, and only title and value are read from objects by default unless you enable item-props

Temporal fix for multiple select with checkbox based on previous comments and source code for the item slot (also checking if the list item is an object or not):

<template #item="{item, props}">
  <VDivider v-if="typeof item.raw === 'object' && 'divider' in item.raw" />
  <VListSubheader
    v-else-if="typeof item.raw === 'object' && 'header' in item.raw"
    :title="item.raw.header"
  />
  <VListItem
    v-else
    v-bind="props"
    :label="item.title"
    :value="item.value"
  >
    <template #prepend="status">
      <VCheckboxBtn
        :key="item.value"
        :modelValue="status.isSelected"
        :ripple="false"
        tabindex="-1"
      />
    </template>
  </VListItem>
</template>

Would be better though if the code is working as the docs, so we as developers don't need to recode the whole core functionality again.

@func0der
Copy link

func0der commented May 27, 2024

opened a rebased variant of the original PR from @nekosaur
Maybe you guys can chime in on that one :)

#19912

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 C: VSelect VSelect has workaround T: enhancement Functionality that enhances existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants