TreeItem
TreeItem is the recursive data record used by TreeView.
Each item represents one node in a hierarchy. It can have its own label, optional icon, child items, and selection or expansion actions.
Example
use fission::prelude::*;
let item = TreeItem {
id: "src".into(),
icon: None,
label: "src/".into(),
children: vec![TreeItem {
id: "main_rs".into(),
icon: None,
label: "main.rs".into(),
children: vec![],
on_toggle: None,
on_select: Some(open_main_file_action),
}],
on_toggle: Some(toggle_src_folder_action),
on_select: Some(select_src_folder_action),
};
Field table
| | | |
|---|
| | | Required. Used by TreeView.expanded_ids and selected_id. |
| | Optional leading icon source. | |
| | | |
| | Child widgets nested under this item. | Defaults to an empty list. |
| | Intended expansion-toggle action. | Present in the public struct, but see note below. |
| | Action fired when the row is selected. | |
Current implementation note
TreeItem exposes on_toggle, but the checked-in TreeView renderer does not currently render a separate expansion affordance or invoke that action for you. Expansion is still reflected through expanded_ids, but the interaction path must be composed carefully at the app level.
Production checklist
For TreeItem, review the fields that change behavior before treating the widget as finished: id, icon, label, children, on_toggle, on_select. The goal is to make the product rule visible in state and actions, not hidden inside ad-hoc construction code.
Bind on_toggle, on_select to explicit reducer actions and test that the reducer handles unavailable, duplicate, or invalid input safely.
When child widgets are generated from data, give reordered or filtered rows an explicit WidgetId so retained local state and scroll behavior do not drift between items.
Set id only when identity must be stable across filtering, reordering, diagnostics, or tests; otherwise let Fission derive identity from structure.
Check the semantics tree for the user-facing label or role that makes this widget understandable without relying only on pixels.
Add at least one component or harness test that confirms the visible text, semantic role, action dispatch, and layout constraint that matter for this widget in context.
If a screen starts repeating the same TreeItem setup, extract a named component around this widget. That keeps the reference API small while making product code easier to read and safer for generated code to copy.
TreeView, Breadcrumb, Icon, and Text.