Skip to content

Commit

Permalink
fix(VListGroup): don't clear opened on unmount (#20215)
Browse files Browse the repository at this point in the history
fixes #20199
  • Loading branch information
lzl0304 authored Jul 23, 2024
1 parent b94f2b9 commit 1e183ef
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { VListGroup } from '../VListGroup'
import { VListItem } from '../VListItem'
import { VList } from '../VList'

// Utilities
import { ref } from 'vue'

describe('VListGroup', () => {
function mountFunction (content: JSX.Element) {
return cy.mount(() => content)
Expand Down Expand Up @@ -49,4 +52,43 @@ describe('VListGroup', () => {

wrapper.get('.v-list-item-title').contains('Group')
})

it('should not remove opened when unmounted', () => {
const visible = ref(true)
const opened = ref(['Users'])
const wrapper = mountFunction((
<CenteredGrid width="200px">
<h2 class="mt-8">ListGroup</h2>

<VList opened={ opened.value }>
{
visible.value && (
<VListGroup value="Users">
{{
default: () => (
<>
<VListItem title="Foo" />
<VListItem title="Bar" />
</>
),
}}
</VListGroup>
)
}
</VList>
</CenteredGrid>
))

wrapper.get('.v-list .v-list-group').should('exist')
.get('.v-list-group__items').should('be.visible')
.then(() => {
visible.value = false
})
.get('.v-list.v-list-group').should('not.exist')
.then(() => {
visible.value = true
})
.get('.v-list-group').should('exist')
.get('.v-list-group__items').should('be.visible')
})
})
1 change: 0 additions & 1 deletion packages/vuetify/src/composables/nested/nested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export const useNested = (props: NestedProps) => {
children.value.set(parent, list.filter(child => child !== id))
}
parents.value.delete(id)
opened.value.delete(id)
},
open: (id, value, event) => {
vm.emit('click:open', { id, value, path: getPath(id), event })
Expand Down

0 comments on commit 1e183ef

Please # to comment.