QTree expanded children stay hidden after being restored
Minimal reproduction using unchanged Quasar 2.35.2 and Vue 3.5.43
HTML
<script src="https://cdn.jsdelivr.net/npm/vue@3.5.43/dist/vue.global.prod.js"></script>
<script src="https://cdn.jsdelivr.net/npm/quasar@2.35.2/dist/quasar.umd.prod.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/quasar@2.35.2/dist/quasar.prod.css">
<div id="q-app">
<main>
<h1>QTree: restored children become hidden</h1>
<p>Click the button, then select Child. Root should stay expanded and Child should remain visible.</p>
<button id="refresh" @click="refreshChildren">Remove and restore children</button>
<q-tree :nodes="nodes" node-key="id" v-model:expanded="expanded" v-model:selected="selected" @after-show="shows++" @after-hide="hides++"></q-tree>
<p>Expanded: <output id="expanded">{{ expanded.join(', ') }}</output></p>
<p>Selected: <output id="selected">{{ selected || 'none' }}</output></p>
<p>Transition events: show=<output id="shows">{{ shows }}</output>, hide=<output id="hides">{{ hides }}</output></p>
</main>
</div>
CSS
main { max-width: 700px; margin: 32px auto; padding: 16px; font: 16px system-ui, sans-serif; }
h1 { font-size: 24px; line-height: 1.4; }
button { margin: 8px 0 24px; padding: 10px 16px; }
JavaScript
const { createApp, nextTick, ref } = Vue
createApp({
setup () {
const originalNodes = [{
id: 'root',
label: 'Root',
children: [{ id: 'child', label: 'Child' }]
}]
const nodes = ref(originalNodes)
const expanded = ref(['root'])
const selected = ref(null)
const shows = ref(0)
const hides = ref(0)
function refreshChildren () {
nodes.value = [{ id: 'root', label: 'Root', children: [] }]
nextTick(() => {
nodes.value = originalNodes
})
}
return { nodes, expanded, selected, shows, hides, refreshChildren }
}
}).use(Quasar).mount('#q-app')