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(VTreeview): indeterminate state no longer based on parent #10021

Closed

Conversation

skycow
Copy link

@skycow skycow commented Dec 20, 2019

Description

A Treeview node no longer sets it's indeterminate state based on it's parent. The indeterminate
state is only set by the default state, the node's previous state, or by the states of the node's
children. A new leaf node with no children that is added will now only be set to selected if the parent is selected and will not be selected if the parent is not selected or indeterminate. If a new node does have children, it can only get set to indeterminate based on the children, not on the parent.

Motivation and Context

fix #8256

How Has This Been Tested?

Visually

Markup:

<template>
  <v-container>
    <v-treeview
      selectable
      :items="items"
    ></v-treeview>
    <v-btn
      width="200"
      color="primary"
      @click="addItem"
    >Add Item</v-btn>
  </v-container>
</template>

<script>
export default {
  data: () => ({
    maxId: 25,
    items: [
      {
        id: 1,
        name: 'Applications :',
        children: [
          { id: 2, name: 'Calendar : app' },
          { id: 3, name: 'Chrome : app' },
          { id: 4, name: 'Webstorm : app' },
        ],
      },
      {
        id: 5,
        name: 'Documents :',
        children: [
          {
            id: 6,
            name: 'vuetify :',
            children: [
              {
                id: 7,
                name: 'src :',
                children: [
                  { id: 8, name: 'index : ts' },
                  { id: 9, name: 'bootstrap : ts' },
                ],
              },
            ],
          },
          {
            id: 10,
            name: 'material2 :',
            children: [
              {
                id: 11,
                name: 'src :',
                children: [
                  { id: 12, name: 'v-btn : ts' },
                  { id: 13, name: 'v-card : ts' },
                  { id: 14, name: 'v-window : ts' },
                ],
              },
            ],
          },
        ],
      },
      {
        id: 15,
        name: 'Downloads :',
        children: [
          { id: 16, name: 'October : pdf' },
          { id: 17, name: 'November : pdf' },
          { id: 18, name: 'Tutorial : html' },
        ],
      },
      {
        id: 19,
        name: 'Videos :',
        children: [
          {
            id: 20,
            name: 'Tutorials :',
            children: [
              { id: 21, name: 'Basic layouts : mp4' },
              { id: 22, name: 'Advanced techniques : mp4' },
              { id: 23, name: 'All about app : dir' },
            ],
          },
          { id: 24, name: 'Intro : mov' },
          { id: 25, name: 'Conference introduction : avi' },
        ],
      },
    ],
  }),
  methods: {
    addItem() {
      this.maxId += 1;
      this.items[0].children.push({ id: this.maxId, name: "Another: app" });
    }
  }
}
</script>

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any features but makes things better)

Checklist:

  • The PR title is no longer than 64 characters.
  • The PR is submitted to the correct branch (master for bug fixes and documentation updates, dev for new features and breaking changes).
  • My code follows the code style of this project.
  • I've added relevant changes to the documentation (applies to new features and breaking changes in core library)
  • I've added new examples to the kitchen (applies to new features and breaking changes in core library)

…rent, only by it's children

A Treeview node no longer sets it's indeterminate state based on it's parent. The indeterminate
state is only set by the default state, the node's previous state, or by the states of the node's
children.

fix vuetifyjs#8256
@jacekkarczmarczyk
Copy link
Member

Can you add a unit test?

@KaelWD KaelWD requested a review from nekosaur December 21, 2019 12:22
@johnleider johnleider added C: VTreeview VTreeview T: bug Functionality that does not work as intended/expected labels Jan 7, 2020
@johnleider johnleider changed the title fix(vtreeview): indeterminate state no longer based on parent fix(VTreeview): indeterminate state no longer based on parent Jan 7, 2020
@johnleider johnleider added this to the v2.2.x milestone Jan 7, 2020
@johnleider
Copy link
Member

@skycow please add a corresponding unit test

@johnleider
Copy link
Member

Fixed in adbb374

If you have any additional questions, please reach out to us in our Discord community.

@johnleider johnleider closed this Jan 29, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: VTreeview 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] New treeview items set indeterminate state based on parent
3 participants