Skip to content

Conversation

@J-Sek
Copy link
Contributor

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

fixes #22366

classic selection requires refresh to re-evaluate on/off/indeterminate, but currently it is only run for selection interactions, so it will set new "disabled" items to "off" and the visual state becomes out of sync

Simply forcing the in(...) call with selected.value = new Map(selected.value) could help, but has other unintended consequences. Leaving it as-is. Improvement may be breaking and should be evaluated for v4.x

Markup:

<template>
  <v-app theme="dark">
    <v-container max-width="800">
      <v-switch v-model="locked" label="lock edits (some nodes)" hide-details />

      <div class="d-flex ga-8">
        <v-list
          v-model:selected="selected"
          :items="items"
          :opened="[1, 5, 6, 10]"
          class="flex-1-1-0"
          collapse-icon=""
          item-value="id"
          select-strategy="classic"
          item-props
          @update:opened=""
        >
          <template #header="{ props }">
            <v-list-item v-bind="props" :ripple="false" tabindex="-1">
              <template #prepend="{ isIndeterminate, isSelected, select }">
                <v-checkbox-btn
                  :indeterminate="isIndeterminate"
                  :model-value="isSelected"
                  @click.prevent="select(!isSelected)"
                  @keydown.enter="select(!isSelected)"
                />
              </template>
            </v-list-item>
          </template>
          <template #item="{ props }">
            <v-list-item v-bind="props" :ripple="false" tabindex="-1">
              <template #prepend="{ isIndeterminate, isSelected, select }">
                <v-checkbox-btn
                  :indeterminate="isIndeterminate"
                  :model-value="isSelected"
                  @click.prevent="select(!isSelected)"
                  @keydown.enter="select(!isSelected)"
                />
              </template>
              <template #append="{ isDisabled }">
                <v-icon v-if="isDisabled" icon="mdi-lock" size="20" />
              </template>
            </v-list-item>
          </template>
        </v-list>
        <v-treeview
          v-model:selected="selected"
          :items="items"
          :opened="[1, 5, 6, 10]"
          class="flex-1-1-0"
          collapse-icon=""
          item-value="id"
          select-strategy="classic"
          item-props
          selectable
          @update:opened=""
        />
      </div>
      <pre class="mt-6">selected: {{ String(selected) }}</pre>
    </v-container>
  </v-app>
</template>

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

  const locked = ref(true)
  const selected = ref([])
  const items = computed(() => [
    {
      id: 1,
      title: 'Applications :',
      children: [
        { id: 2, title: 'Calendar', disabled: locked.value },
        { id: 3, title: 'Chrome' },
        { id: 4, title: 'Webstorm' },
      ],
    },
    {
      id: 5,
      title: 'Documents :',
      children: [
        {
          id: 6,
          title: 'Taxes :',
          children: [
            { id: 8, title: 'Report 2024.xlsx', disabled: locked.value },
            { id: 9, title: 'Report 2025.xlsx', disabled: locked.value },
          ],
        },
      ],
    },
    {
      id: 10,
      title: 'Other :',
      disabled: locked.value,
      children: [
        { id: 11, title: 'other doc 1' },
        { id: 12, title: 'other doc 2' },
      ],
    },
  ])
</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
@J-Sek J-Sek closed this Dec 20, 2025
@J-Sek J-Sek reopened this Dec 20, 2025
@J-Sek J-Sek merged commit 11125d8 into master Dec 20, 2025
10 of 12 checks passed
@J-Sek J-Sek deleted the fix/vlist-disabled-selectable branch December 20, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VList 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.11.1] VListItem :disabled doesn't allow VList vmodel:selected to update

1 participant