Skip to content

test: reproduce createComponent children selection gap#26

Merged
vparys merged 2 commits intomainfrom
test/createcomponent-children-selection
Apr 23, 2026
Merged

test: reproduce createComponent children selection gap#26
vparys merged 2 commits intomainfrom
test/createcomponent-children-selection

Conversation

@vparys
Copy link
Copy Markdown
Member

@vparys vparys commented Apr 23, 2026

Summary

  • Adds a failing test documenting that when a createComponent wraps other bindx components via children, the child's own selection is never merged into the fetch plan.
  • Root cause: analyzer.ts stops at any component exposing getSelection (no recursion into props.children), and createGetSelection in componentFactory.ts receives collectNested as _collectNested and never invokes it. Every other selection-providing component (<If>, <Show>, <HasOne>, <HasMany>, <Switch>, <Attribute>) does call it.
  • Runtime symptom: UnfetchedFieldError the moment the child accessor reads a field only its own createComponent selection declared.

Test plan

  • bun test tests/selectionCollection.test.tsx — expect the new case createComponent children via \children` prop contribute to selectionto fail onexpect(selection.fields.has('label')).toBe(true)`; all 12 existing cases still pass.
  • Once the fix lands (either have createGetSelection call collectNested(props.children), or have analyzeJsx recurse into children after getSelection when a component renders its children verbatim), the new test flips to green with no other regressions.

vparys and others added 2 commits April 23, 2026 15:02
When a createComponent wraps other bindx components via `children`,
analyzeJsx does not descend into them and createGetSelection ignores
the `collectNested` callback, so the child's own selection is missing
from the fetch plan.

Test currently fails — documents the bug for a follow-up fix.
…lected

analyzeJsx stopped at any component exposing getSelection and never
recursed into its children. createGetSelection in componentFactory
discarded collectNested and never invoked it. Children that were
themselves createComponent instances had their selection silently
dropped, surfacing at runtime as UnfetchedFieldError.

Introduce .slots(names) on the component builder. Listed props are
walked via collectNested after the wrapper's own selection is computed,
so each slot's nested bindx components contribute to the fetch plan.
Default is ['children']; pass [] to opt out, or a custom list to
analyze other ReactNode-shaped props (header, footer, etc.).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vparys vparys merged commit 245d0cb into main Apr 23, 2026
3 checks passed
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.

2 participants