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(VList): don't render vlistgroup when children is empty array #18174

Closed
wants to merge 2 commits into from

Conversation

mlankamp
Copy link

fixes #18172

Description

The current implementation of VList is to render a VListGroup when the children property is an empty array. This change adds an additional check on the length of the array. When the array is empty a VListItem is rendered.

Markup:

<template>
  <v-app>
    <v-container>
      <code>{{ selection }}</code>
      <v-list v-model:selected="selection" :items="items" item-title="name" item-value="id" select-strategy="classic">
        <template #prepend="{ isSelected, select }">
          <v-checkbox-btn :model-value="isSelected" @update:model-value="select" />
        </template>
      </v-list>
    </v-container>
  </v-app>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const selection = ref([])

const items = [
  {
    name: 'Item #1 (empty array)',
    id: 1,
    children: [
      {
        name: 'Item #1-1',
        id: 11,
        children: [],
      },
    ],
  },
  {
    name: 'Item #2 (undefined)',
    id: 2,
    children: [
      {
        name: 'Item #2-1',
        id: 21,
        children: undefined,
      },
    ],
  },
  {
    name: 'Item #3 (null)',
    id: 3,
    children: [
      {
        name: 'Item #3-1',
        id: 31,
        children: null,
      },
    ],
  },
]
</script>

@mlankamp mlankamp closed this Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.3.14] VList with selection doesn't work when children is an empty array
1 participant