Skip to content

Conversation

@J-Sek
Copy link
Contributor

@J-Sek J-Sek commented Oct 26, 2025

fixes #21720

Introduces items-registration prop - "props" | "render" (set to "render" for backward compatibility).
When set to "props", registration of nested items won't require rendering VListItems.

Note: Change to "props" (as default) should be considered for v4.0.0.

Markup:

<template>
  <v-app theme="dark">
    <v-container>
      <div v-if="loading" style="position: absolute; top: 50%; left: 30%">
        <v-progress-circular
          color="blue"
          size="40"
          width="2"
          indeterminate
        />
      </div>
      <v-treeview
        v-else
        :items="items"
        density="compact"
        item-title="NEV"
        item-value="S_ID"
        items-registration="props"
        select-strategy="classic"
        activatable
        hoverable
        open-on-click
        selectable
      >
        <template #title="{ title, item }">
          #{{ item.S_ID }} | {{ title }}
        </template>
      </v-treeview>
    </v-container>
  </v-app>
</template>

<script setup>
  import { onMounted, shallowRef } from 'vue'

  const loading = shallowRef(false)
  const items = shallowRef([])
  onMounted(() => getData())
  async function getData () {
    loading.value = true
    const response = await fetch('https://dummyjson.com/c/f63f-7404-4b5a-be8e')
    items.value = (await response.json()).res

    function countNodes (tree) {
      return tree.length + tree.filter(x => x.children)
        .map(x => x.children ? countNodes(x.children) : 0)
        .reduce((sum, n) => sum + n, 0)
    }
    console.log('loaded nodes:', countNodes(items.value))
    loading.value = false
  }
</script>

@J-Sek J-Sek self-assigned this Oct 26, 2025
@J-Sek J-Sek added C: VTreeview C: VList performance The issue involves performance labels Oct 26, 2025
@J-Sek J-Sek requested a review from KaelWD October 26, 2025 20:58
@KaelWD
Copy link
Member

KaelWD commented Oct 28, 2025

Does not support links, so you might need to set item-value to href, to or a custom resolver function.

Do you have an example of what specifically is broken by this?

@KaelWD
Copy link
Member

KaelWD commented Oct 28, 2025

Related: #21325

@J-Sek
Copy link
Contributor Author

J-Sek commented Oct 28, 2025

Does not support links, so you might need to set item-value to href, to or a custom resolver function.

Do you have an example of what specifically is broken by this?

<template>
  <v-app theme="dark">
    <v-container>
      <v-treeview
        :items="items"
        items-registration="props"
        select-strategy="classic"
        selectable
      />
    </v-container>
  </v-app>
</template>

<script setup>
  const items = [
    {
      value: 'group-1',
      title: 'Components',
      children: [
        // missing explicit `value=...`, won't be picked up by items-registration="props"
        { href: 'https://vuetifyjs.com/en/components/treeview', title: 'Treeview' },
        { href: 'https://vuetifyjs.com/en/components/buttons', title: 'Buttons' },
        { href: 'https://vuetifyjs.com/en/components/cards', title: 'Cards' },
      ],
    },
  ]
</script>

@KaelWD
Copy link
Member

KaelWD commented Oct 28, 2025

That doesn't seem to be any different to on master. Playground

@KaelWD
Copy link
Member

KaelWD commented Oct 28, 2025

return-object is currently broken, with items-registration="render" id is actually the entire object here

activate: (id, value, event) => {
and also the keys in the children and parents maps

@J-Sek
Copy link
Contributor Author

J-Sek commented Oct 28, 2025

Restored support for return-object. I don't like how it leaks into nested.ts... In the ideal world it should probably be scoped to the transformOut on the selection model.

@J-Sek J-Sek force-pushed the jsek/vtreeview-faster-interactions branch from 595d7d5 to ee78e37 Compare November 12, 2025 01:34
@J-Sek J-Sek enabled auto-merge (squash) November 12, 2025 01:50
@J-Sek J-Sek disabled auto-merge November 12, 2025 02:06
@J-Sek J-Sek merged commit 9d5a1d4 into dev Nov 12, 2025
18 checks passed
@J-Sek J-Sek deleted the jsek/vtreeview-faster-interactions branch November 12, 2025 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: VList C: VTreeview performance The issue involves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][3.9.0] VTreeview slow load and freezes browser when using many groups

4 participants