Skip to content

Conversation

@metonym
Copy link
Collaborator

@metonym metonym commented Oct 8, 2025

Summary

  • Add selectNode(id) imperative method to TreeView
  • Allows programmatic node selection without changing focus or expansion state
  • Includes TypeScript definitions, unit tests, and documentation

Changes

  • Implementation: Added selectNode(id) method in TreeView.svelte
  • Types: Updated TypeScript definitions in TreeView.svelte.d.ts
  • Tests: Added unit test verifying selection without side effects
  • Docs: Created example demonstrating the new method

Use Case

Previously, selecting a node programmatically required either:

  • User interaction (clicking)
  • Using showNode() which also expands ancestors and changes focus

Now selectNode() provides a lighter-weight option for just updating selection state.

Test plan

  • Unit tests pass (npm test -- TreeView.test.ts)
  • Method correctly updates selectedIds
  • Method does not expand nodes
  • Method does not trigger select event
  • Documentation example created

@metonym metonym changed the title feat(TreeView): add selectNode method feat(tree-view): add selectNode method Oct 8, 2025
Add imperative selectNode(id) method to programmatically select a node
without changing focus or expansion state. This fills a gap where
selection was previously only possible through user interaction or the
more invasive showNode method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant