Skip to content

Conversation

@J-Sek
Copy link
Contributor

@J-Sek J-Sek commented Dec 20, 2025

fixes #22353

Markup:

(also check the more complex demo from #22464)

  • not enough to fully fix VList
<template>
  <v-app theme="dark">
    <v-container max-width="800">
      <v-select
        v-model="strategy"
        :items="['classic', 'leaf', 'independent', 'trunk', 'branch']"
        prefix="strategy:"
      />
      <v-alert v-if="strategy === 'branch'">This strategy requires v3.12.0 or later</v-alert>
      <div class="d-flex ga-6">
        <v-treeview
          :key="reset"
          v-model:selected="selected"
          :item-props="(item) => ({ disabled: !enabledItems.find(x => x.key === item.value)?.value })"
          :items="items"
          :open-all="true"
          :select-strategy="strategy"
          class="flex-1-1-0"
          selectable
        />

        <v-treeview
          v-model:selected="selected"
          :items="items"
          :open-all="true"
          :select-strategy="strategy"
          class="flex-1-1-0"
          selectable
        />

        <v-list class="flex-1-1-0">
          <v-list-item v-for="(item) in enabledItems" :key="item.key" :title="item.key">
            <template #append>
              <v-switch v-model="item.value" class="ml-n10" density="compact" hide-details />
            </template>
          </v-list-item>
        </v-list>
      </div>
      <pre>{{ selected }}</pre>

      <v-btn class="text-none" text="Reset left tree" @click="reset++" />
    </v-container>
  </v-app>
</template>

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

  const reset = ref(0)
  const strategy = ref('classic' as any)

  const items = [
    {
      title: 'parent',
      value: 'parent',
      children: [
        {
          title: 'child1',
          value: 'child1',
        },
        {
          title: 'child2',
          value: 'child2',
        },
      ],
    },
  ]

  function bfsFlatten (items: any[]): any[] {
    const result = []
    for (const item of items) {
      result.push(item)
      if (item.children?.length) {
        result.push(...bfsFlatten(item.children))
      }
    }
    return result
  }
  const enabledItems = ref(bfsFlatten(items).map(x => ({ key: x.value, value: false })))

  const selected = ref(['child1'])
</script>

@J-Sek J-Sek self-assigned this Dec 20, 2025
@J-Sek J-Sek added T: bug Functionality that does not work as intended/expected C: VTreeview C: VList labels Dec 20, 2025
fixes #22353

loading selection state
'fix/vlist-disabled-loading-selections' on 'b58e36119'.
packages/vuetify/src/composables/nested/selectStrategies.ts
@J-Sek J-Sek force-pushed the fix/vlist-disabled-loading-selections branch from 373f674 to 5480374 Compare December 20, 2025 21:32
@J-Sek J-Sek changed the title fix(VList, VTreeview): bypass disabled when loading selection state fix(VTreeview): bypass disabled when loading selection state Dec 20, 2025
@J-Sek J-Sek removed the C: VList label Dec 20, 2025
@J-Sek J-Sek added this to the v3.11.x milestone Dec 22, 2025
@J-Sek J-Sek merged commit 70dd313 into master Dec 22, 2025
16 checks passed
@J-Sek J-Sek deleted the fix/vlist-disabled-loading-selections branch December 22, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VTreeview 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.10.11] VTreeview displays selection incorrectly when using classic select strategy while disabled

1 participant