Skip to content
Discussion options

You must be logged in to vote

This is working as expected. When selectedValue is provided, the component runs in controlled mode — it always reflects the value you pass and won't update internally on click.

Make sure you're using a signal and passing both props:

const [selectedValue, setSelectedValue] = createSignal<string[]>([])

<TreeView.Root
  selectedValue={selectedValue()}
  onSelectionChange={({ selectedValue }) => setSelectedValue(selectedValue)}
>
  {/* ... */}
</TreeView.Root>

If you want to prevent selection entirely, pass a static value without updating in the callback.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by segunadebayo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants