Skip to content

feat: add virtual-aware component tree traversal helpers#24408

Open
Artur- wants to merge 5 commits into
mainfrom
feature/getallchildren
Open

feat: add virtual-aware component tree traversal helpers#24408
Artur- wants to merge 5 commits into
mainfrom
feature/getallchildren

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 22, 2026

Adds ComponentUtil.getAllChildren and ComponentUtil.streamDescendants. Unlike Component.getChildren, these include components attached as virtual children (slotted helpers like addToFooter, overlays attached to the UI, the client-side routing wrapper), so tools that need a complete component tree no longer have to reach into internal APIs such as VirtualChildrenList.

Adds ComponentUtil.getAllChildren and ComponentUtil.streamDescendants.
Unlike Component.getChildren, these include components attached as
virtual children (slotted helpers like addToFooter, overlays attached
to the UI, the client-side routing wrapper), so tools that need a
complete component tree no longer have to reach into internal APIs
such as VirtualChildrenList.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

Test Results

 1 420 files  ±0   1 420 suites  ±0   1h 22m 6s ⏱️ - 1m 38s
10 006 tests +7   9 938 ✅ +7  68 💤 ±0  0 ❌ ±0 
10 478 runs  +7  10 409 ✅ +7  69 💤 ±0  0 ❌ ±0 

Results for commit d8ab222. ± Comparison against base commit 7c1186a.

♻️ This comment has been updated with latest results.

StateNode.getFeatureIfInitialized throws when the node isn't
configured for the requested feature, and text-node StateNodes
created by BasicTextElementStateProvider don't have
VirtualChildrenList. The recursive descent in getAllChildren and
streamDescendants therefore crashed when a non-component wrapper
element had a text-node child. Mirror the hasFeature guard used by
Element.informChildrenOfStateChange.
@Artur- Artur- marked this pull request as ready for review May 22, 2026 08:28
Comment thread flow-server/src/main/java/com/vaadin/flow/component/ComponentUtil.java Outdated
Artur- added 3 commits May 22, 2026 12:49
Also fix the error message: Component.wrapAndMap does not exist; the
canonical way to create a Component that maps back to its Element is
Component.from(Element, Class). The identical wording in the existing
getChildren and getParent messages references the same missing method,
but cleaning those up is out of scope for this PR.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants