Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(VTreeview): port open-on-click prop to v3 & enhancement #20038

Merged
merged 14 commits into from
Jul 9, 2024

Conversation

yuwu9145
Copy link
Member

@yuwu9145 yuwu9145 commented Jun 21, 2024

New props being ported from v2:

  • open-on-click to allow explicitly defining group activator behaviour
  • selected-color

fixes all broken examples on doc
fixes return-object doesn't work for "open", "select" and "activate"
fixes #20009
fixes #20095
fixes #19414
fixes #20106

Need extra eyes on testing. This PR aims to resolve all obvious known treeview issues, you can start testing from going through docs & checking playground. Feel free to report any weird behaviours/issues

Description

Markup:

<template>
  <h2>Activatable (independent)</h2>
  <v-treeview
    :items="items"
    item-title="title"
    item-value="id"
    activatable
    @update:activated="activateSelectCallback"
  />
  <h2>Activatable (independent) - Open-on-click</h2>
  <v-treeview
    :items="items"
    item-title="title"
    item-value="id"
    activatable
    open-on-click
    @update:activated="activateSelectCallback"
  />
  <h2>Activatable (single-independent)</h2>
  <v-treeview
    :items="items"
    active-strategy="single-independent"
    color="red"
    item-title="title"
    item-value="id"
    activatable
    @update:activated="activateSelectCallback"
  />
  <h2>Activatable (single-independent) - Open-on-click</h2>
  <v-treeview
    :items="items"
    active-strategy="single-independent"
    color="red"
    item-title="title"
    item-value="id"
    activatable
    open-on-click
    @update:activated="activateSelectCallback"
  />
  <h2>Activatable (single-leaf)</h2>
  <v-treeview
    :items="items"
    active-strategy="single-leaf"
    color="red"
    item-title="title"
    item-value="id"
    activatable
    @update:activated="activateSelectCallback"
  />
  <h2>Activatable (single-leaf) - Open-on-click</h2>
  <v-treeview
    :items="items"
    active-strategy="single-leaf"
    color="red"
    item-title="title"
    item-value="id"
    activatable
    open-on-click
    @update:activated="activateSelectCallback"
  />
  <h2>Activatable (leaf)</h2>
  <v-treeview
    :items="items"
    active-strategy="leaf"
    color="red"
    item-title="title"
    item-value="id"
    activatable
    @update:activated="activateSelectCallback"
  />
  <h2>Activatable (leaf) - Open-on-click</h2>
  <v-treeview
    :items="items"
    active-strategy="leaf"
    color="red"
    item-title="title"
    item-value="id"
    activatable
    open-on-click
    @update:activated="activateSelectCallback"
  />
  <h2>Selectable (single-leaf)</h2>
  <v-treeview
    :items="items"
    color="red"
    item-title="title"
    item-value="id"
    select-strategy="single-leaf"
    selectable
    @update:selected="activateSelectCallback"
  />
  <h2>Selectable (leaf)</h2>
  <v-treeview
    :items="items"
    color="red"
    item-title="title"
    item-value="id"
    select-strategy="leaf"
    selectable
    @update:selected="activateSelectCallback"
  />
  <h2>Selectable (independent)</h2>
  <v-treeview
    :items="items"
    color="red"
    item-title="title"
    item-value="id"
    select-strategy="independent"
    selectable
    @update:selected="activateSelectCallback"
  />
  <h2>Selectable (single-independent)</h2>
  <v-treeview
    :items="items"
    color="red"
    item-title="title"
    item-value="id"
    select-strategy="single-independent"
    selectable
    @update:selected="activateSelectCallback"
  />
  <h2>Selectable (classic)</h2>
  <v-treeview
    :items="items"
    color="red"
    item-title="title"
    item-value="id"
    select-strategy="classic"
    selectable
    selected-color="green"
    open-on-click
    @update:selected="activateSelectCallback"
  />
  <!-- <v-treeview
    :items="items"
    @update:activated="activateSelectCallback"
  /> -->
</template>

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

  function activateSelectCallback ( e ) {
    console.log('activateCallback', e)
  }
  const items = ref([
    {
      id: 1,
      title: 'Applications :',
      children: [
        { id: 2, title: 'Calendar : app' },
        { id: 3, title: 'Chrome : app' },
        { id: 4, title: 'Webstorm : app' },
      ],
    },
    {
      id: 5,
      title: 'Documents :',
      children: [
        {
          id: 6,
          title: 'vuetify :',
          children: [
            {
              id: 7,
              title: 'src :',
              children: [
                { id: 8, title: 'index : ts' },
                { id: 9, title: 'bootstrap : ts' },
              ],
            },
          ],
        },
        {
          id: 10,
          title: 'material2 :',
          children: [
            {
              id: 11,
              title: 'src :',
              children: [
                { id: 12, title: 'v-btn : ts' },
                { id: 13, title: 'v-card : ts' },
                { id: 14, title: 'v-window : ts' },
              ],
            },
          ],
        },
      ],
    },
    {
      id: 15,
      title: 'Downloads :',
      children: [
        { id: 16, title: 'October : pdf' },
        { id: 17, title: 'November : pdf' },
        { id: 18, title: 'Tutorial : html' },
      ],
    },
    {
      id: 19,
      title: 'Videos :',
      children: [
        {
          id: 20,
          title: 'Tutorials :',
          children: [
            { id: 21, title: 'Basic layouts : mp4' },
            { id: 22, title: 'Advanced techniques : mp4' },
            { id: 23, title: 'All about app : dir' },
          ],
        },
        { id: 24, title: 'Intro : mov' },
        { id: 25, title: 'Conference introduction : avi' },
      ],
    },
  ])
</script>


@yuwu9145 yuwu9145 force-pushed the feat-open-on-click branch from ce26a2e to 95de09e Compare July 5, 2024 08:08
@yuwu9145 yuwu9145 changed the title Feat(VTreeview): port open-on-click prop to v3 feat(VTreeview): port open-on-click prop to v3 & enhancement Jul 5, 2024
@yuwu9145 yuwu9145 marked this pull request as ready for review July 5, 2024 09:21
@uccmen
Copy link

uccmen commented Jul 5, 2024

omg I need this PR merged by Monday 🥲😂🫡🙌🏽

@ConnorNoddin
Copy link

omg I need this PR merged by Monday 🥲😂🫡🙌🏽

Seconded

@johnleider johnleider added T: bug Functionality that does not work as intended/expected C: VTreeview VTreeview labels Jul 8, 2024
@johnleider johnleider added this to the v3.6.x milestone Jul 8, 2024
Copy link
Member

@johnleider johnleider left a comment

Choose a reason for hiding this comment

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

Looking really good.

packages/vuetify/src/labs/VTreeview/VTreeview.tsx Outdated Show resolved Hide resolved
packages/vuetify/src/labs/VTreeview/VTreeviewChildren.tsx Outdated Show resolved Hide resolved
packages/vuetify/src/labs/VTreeview/VTreeviewItem.tsx Outdated Show resolved Hide resolved
@johnleider johnleider merged commit cb6b5ff into dev Jul 9, 2024
18 checks passed
@johnleider johnleider deleted the feat-open-on-click branch July 9, 2024 15:48
@kvngrnr
Copy link

kvngrnr commented Jul 24, 2024

Any update on when this will be merged/released?

@stephane303
Copy link
Contributor

stephane303 commented Jul 24, 2024

I did some tests, especially around selected, this seems to work but only if return-object is activated.
If return-object is not there :

  • I get [ "Symbol(6)", "Symbol(9)" ] in the selection, and I guess the ids should be there.
  • the behaviour is different than if return-object is activated

@yuwu9145
Copy link
Member Author

I did some tests, especially around selected, this seems to work but only if return-object is activated. If return-object is not there :

  • I get [ "Symbol(6)", "Symbol(9)" ] in the selection, and I guess the ids should be there.
  • the behaviour is different than if return-object is activated

I can't replicate on dev branch, did you have item-value applied or can you provide a sample code?

@stephane303
Copy link
Contributor

I did some tests, especially around selected, this seems to work but only if return-object is activated. If return-object is not there :

  • I get [ "Symbol(6)", "Symbol(9)" ] in the selection, and I guess the ids should be there.
  • the behaviour is different than if return-object is activated

I can't replicate on dev branch, did you have item-value applied or can you provide a sample code?

Yes I did the tests again today, can't see it either again, I am new in running vuetify locally, that was probably the reason why, sorry.

@yuwu9145
Copy link
Member Author

I am new in running vuetify locally

I don't think dev branch is live anywhere so you were playing around live master branch which doesn't have changes in this PR yet.

https://vuetifyjs.com/en/getting-started/contributing/#local-development

# for free to join this conversation on GitHub. Already have an account? # to comment
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.

6 participants