Skip to content

fix(VDataTable): expand rows when items are plain array#22109

Merged
KaelWD merged 2 commits intomasterfrom
fix/vdatatable-expand
Sep 24, 2025
Merged

fix(VDataTable): expand rows when items are plain array#22109
KaelWD merged 2 commits intomasterfrom
fix/vdatatable-expand

Conversation

@J-Sek
Copy link
Copy Markdown
Contributor

@J-Sek J-Sek commented Sep 23, 2025

  • when we add plain objects to the Set, model gets "proxied", so they change and won't match - has(), delete() do not work
  • (prior to #21128) only happened when using return-object and plain array of items

fixes #22080
reverts #21128

Markup:

<template>
  <v-app theme="dark">
    <v-container>
      <v-data-table
        v-model:expanded="expanded1"
        :headers="headers"
        :items="items1"
        hide-default-footer
        return-object
        show-expand
      >
        <template #expanded-row="data"> {{ data.item }} </template>
      </v-data-table>
      <pre>expanded1: {{ JSON.stringify(expanded1) }}</pre>

      <v-divider />

      <v-data-table
        v-model:expanded="expanded2"
        :headers="headers"
        :items="items2"
        hide-default-footer
        return-object
        show-expand
      >
        <template #expanded-row="data"> {{ data.item }} </template>
      </v-data-table>
      <pre>expanded2: {{ JSON.stringify(expanded2) }}</pre>
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref } from 'vue'
  const headers = [
    { title: 'Title', value: 'title' },
    { title: 'value', value: 'value' },
  ]

  const items1 = [
    { title: 'A', value: 1 },
    { title: 'B', value: 2 },
    { title: 'C', value: 3 },
  ]

  const items2 = ref([
    { title: 'A', value: 1 },
    { title: 'B', value: 2 },
    { title: 'C', value: 3 },
  ])

  const expanded1 = ref([items1[0]])
  const expanded2 = ref([items2.value[2]])
</script>

@J-Sek J-Sek self-assigned this Sep 23, 2025
@J-Sek J-Sek added T: bug Functionality that does not work as intended/expected T: regression Something that used to work but we broke C: VDataTable labels Sep 23, 2025
@J-Sek J-Sek requested a review from KaelWD September 23, 2025 11:55
@KaelWD
Copy link
Copy Markdown
Member

KaelWD commented Sep 24, 2025

Adding this to #21731

#21128 was definitely incorrect, it "fixed" the problem by making return-object do nothing.

@KaelWD KaelWD merged commit d8b5c4a into master Sep 24, 2025
19 checks passed
@KaelWD KaelWD deleted the fix/vdatatable-expand branch September 24, 2025 08:34
@KaelWD KaelWD added this to the v3.10.x milestone Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VDataTable T: bug Functionality that does not work as intended/expected T: regression Something that used to work but we broke

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][3.10.2] VDataTable expanded v-model (with return object)

2 participants