Prevent selected node to be unselect primevue Tree component

18 views Asked by At

I am using primevue (^3.48.1) Tree component to display a folders & files structure for a note application. I would like to prevent the user to unselect a selected node. In other words, I want the tree to always have a selected node.

I tried to prevent the unselection event propagation, but it is raising an error.

<template>
    <div class="card flex justify-content-center m-auto">
        <Tree
            ref="test"
            class="w-full md:w-30rem"
            :filter="true"
            :value="treeNotes"
            v-model:selection-keys="selectedKey"
            filterMode="lenient"
            selectionMode="single"
            v-model:expandedKeys="expandedKeys"
            @node-select="node => selectNode(node)"
            @node-unselect.prevent
        />
    </div>
</template>

Is there any way I can achieve this behavior ?

0

There are 0 answers