Skip to content
OGE logoOGE

Tree View

<oge-tree-view> renders a hierarchy from either a flat parent-referencing array or nested children. It follows the WAI-ARIA APG treeview pattern — a roving tabindex over role="treeitem" rows, arrow / Home / End / type-ahead navigation and * to open a level — and expresses depth with aria-level / aria-posinset / aria-setsize over a flat DOM, which is what lets it virtualize.

APG pattern signals virtual scroll lazy load

Flat data

The canonical shape: rows carrying a parent reference. expandedKeys and selectedKeys are two-way models keyed by identity, so they survive reordering. The disabled node is skipped by both clicks and arrow keys.

keyExpr parentIdExpr [(expandedKeys)] selectionMode
Documents
Contracts

expandedKeys: 1 · selectedKeys: (none)

Nested data

Point itemsExpr at the children field and the parent links are derived for you — core's flattenNestedTree normalizes the payload into the same single pipeline the flat shape uses.

itemsExpr
src
app
app.ts
app.routes.ts
main.ts
package.json

Checkboxes & cascade

Checking a node cascades down to its descendants and normalizes up: a parent is checked only when every child is, and indeterminate whenever some are. The checkbox is an aria-hidden glyph and the state lives on the row as aria-checked — a real checkbox inside role="treeitem" would be a nested-interactive violation.

showCheckBoxes tri-state selectedKeysMode
Documents
Reports
Q1.pdf
Q2.pdf
Contracts
Photos
Holiday
Archive

selectedKeys: (none)

Matching is accent- and locale-insensitive (core's foldText), the ancestors of a hit are auto-expanded so it is reachable, and the matched substring is wrapped in <mark>. filterMode: 'fullBranch' also keeps a match's descendants.

searchEnabled filterMode highlight

Lazy load on demand

Only the roots are bound; hasItemsExpr tells the tree which of them can expand. The first expand calls loadChildren and the engine renders a placeholder row until it resolves. Fetched children are folded into the index, so cascading selection reaches them.

loadChildren hasItemsExpr skeleton row
readme.txt

Virtual scrolling

Because the tree renders a flat list with aria-level rather than nested groups, it can window the DOM. Built on core's OffsetTree + computeWindow; keyboard focus moves scroll the target into view first, since the row may not exist yet.

virtualScroll 10 000 nodes
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12
Item 13
Item 14
Item 15
Item 16
Item 17
Item 18
Item 19

Drag & drop reparenting

Drag a node onto the middle of another to make it a child, or onto an edge to place it as a sibling. Hovering a collapsed parent opens it, Escape cancels, and a node can never be dropped into its own subtree. The tree emits itemReordered and leaves the data change to you.

allowDragging inside / before / after cycle guard
Documents
Reports
Q1.pdf
Q2.pdf
Contracts
Photos
Holiday
Archive

Drag rules

Rules for what may move where. allowDropBetween: false keeps a sorted tree sorted: nodes go into folders, never between them. itemDragStarting keeps the locked System folder in place, and itemDragOver refuses a spot — files take no children here — so no indicator shows and a drop does nothing. Both are cancelable and also cover the Ctrl+X / Ctrl+V twin.

allowDropBetween itemDragStarting itemDragOver
Projects
Website
brief.pdf
Shared
System
config.json

Drag between trees

Trees that share a dragGroup accept each other's nodes. The target previews the drop zone and fires the cancelable itemReordering and itemReordered with sourceTreeId / targetTreeId; the source fires itemTransferred. Neither tree moves data. The keyboard twin is Ctrl+X on a node and Ctrl+V on the target (Ctrl+Shift+V places it after), announced through the live region; cutItem() / pasteItem() wire the same move to buttons.

dragGroup itemTransferred Ctrl+X / Ctrl+V
Website
Landing page
Pricing page
Mobile app
Onboarding
2024
2023

Label editing (F2)

F2 — or a double-click with editOnDblClick — turns the label into a text field. Enter or blur commits, Escape cancels, and the focus returns to the node. itemEditStarting and itemEditing are cancelable, validateEdit keeps the field open with its message, and itemEdited carries previousValue / value — the tree leaves the data change to you.

allowEditing F2 validateEdit itemEdited
Documents
Contracts

Item context menu

Right-click an item — or press the Menu key / Shift+F10 on the focused one, or long-press it on touch — and itemContextMenu reports the item with an empty items array: push menu items and the tree opens its own menu at the item, labelled by it, with the focus back on the item when it closes. Leave the array empty for an item and the browser menu stays. source tells pointer, touch and keyboard apart.

itemContextMenu Shift+F10 source
Documents
Contracts

Load more paging

With childPageSize a parent renders its first page of children and a “Show N more items” row, which Enter, Space or a click expands by one more page — the focus lands on the first new child. The row is in the arrow-key order, aria-setsize keeps reporting the real total, and paging pauses while searching. Works with virtualScroll too.

childPageSize Load more aria-setsize
Inbox
Message 1
Message 2
Message 3
Message 4
Message 5
Show 18 more items

Custom node template

The item template replaces the built-in label. It renders inside the role="treeitem" row, so it must stay free of focusable controls.

ogeTreeItemTemplate
Documentslevel 0
Contractslevel 1