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(nested): prevent parent node activate firing for singleLeaf #20951

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

yuwu9145
Copy link
Member

@yuwu9145 yuwu9145 commented Jan 31, 2025

Description

fixes #20946

Markup:

<template>
  <v-treeview
    @update:activated="args => console.log('activated', args)"
    :items="items"
    :opened="initiallyOpen"
    item-value="title"
    activatable
    active-strategy="single-leaf"
    open-all
  >
    <template v-slot:prepend="{ item, isOpen }">
      <v-icon v-if="!item.file">
        {{ isOpen ? 'mdi-folder-open' : 'mdi-folder' }}
      </v-icon>
      <v-icon v-else> {{ files[item.file] }} </v-icon>
    </template>
  </v-treeview>
</template>

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

  const initiallyOpen = ref(['public'])
  const files = ref({
    html: 'mdi-language-html5',
    js: 'mdi-nodejs',
    json: 'mdi-code-json',
    md: 'mdi-language-markdown',
    pdf: 'mdi-file-pdf-box',
    png: 'mdi-file-image',
    txt: 'mdi-file-document-outline',
    xls: 'mdi-file-excel',
  })
  const items = ref([
    {
      title: '.git',
    },
    {
      title: 'node_modules',
    },
    {
      title: 'public',
      children: [
        {
          title: 'static',
          children: [
            {
              title: 'logo.png',
              file: 'png',
            },
          ],
        },
        {
          title: 'favicon.ico',
          file: 'png',
        },
        {
          title: 'index.html',
          file: 'html',
        },
      ],
    },
    {
      title: '.gitignore',
      file: 'txt',
    },
    {
      title: 'babel.config.js',
      file: 'js',
    },
    {
      title: 'package.json',
      file: 'json',
    },
    {
      title: 'README.md',
      file: 'md',
    },
    {
      title: 'vue.config.js',
      file: 'js',
    },
    {
      title: 'yarn.lock',
      file: 'txt',
    },
  ])
</script>

@yuwu9145 yuwu9145 marked this pull request as ready for review February 7, 2025 09:57
@@ -378,11 +378,14 @@ export function filterInputAttrs (attrs: Record<string, unknown>) {

/**
* Returns the set difference of B and A, i.e. the set of elements in B but not in A
* A and B can be sets, but the function always returns the result as an array.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KaelWD What do you think of this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they're already sets .has should be faster than .includes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to use symmetricDifference instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuwu9145 yuwu9145 requested a review from KaelWD February 9, 2025 08:09
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.7.9] VTreeView update:activated will be fired if a non activateable node is activated
2 participants