Skip to content

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

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

feat: add virtual-aware component tree traversal helpers#24408
Artur- wants to merge 9 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 421 files  ±0   1 421 suites  ±0   1h 21m 35s ⏱️ + 1m 49s
10 017 tests +7   9 949 ✅ +7  68 💤 ±0  0 ❌ ±0 
10 489 runs  +7  10 420 ✅ +7  69 💤 ±0  0 ❌ ±0 

Results for commit 05dfeea. ± Comparison against base commit d9afcc4.

♻️ 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 4 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.
}

@Test
public void wrappedComponentGetAllChildren() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looking at the code, it is not clear what we are testing. Can we rename the test method to describe the use case? Or add a comment if method rename is not feasible.

Artur- added 3 commits May 25, 2026 22:12
Renames wrappedComponentGetAllChildren to
getAllChildren_throwsForWrappedComponent and explains why Element.as
puts a Component in a state where getAllChildren cannot resolve
children.
@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