Audit ui.* VNode factories and harden interactive prop validation#78
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f915fb88a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (propsRes.value.value.length > 0 | ||
| ? propsRes.value.value |
There was a problem hiding this comment.
Align select measurement fallback with renderer
measureLeaf now uses the raw select.value when no option matches, but the renderer still falls back to the placeholder in that same state (renderToDrawlist/widgets/basic.ts sets label = placeholder when no match is found). When value is non-empty but stale/not present in options (common during async option reloads), measurement can become narrower than rendered text (e.g. value "x" vs rendered " Select… ▼"), which clips the control and destabilizes layout.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in ae17eb4.
I aligned measureLeaf select fallback with renderer behavior: when no option matches value, measurement now falls back to placeholder (default "Select…") instead of the raw stale value.
I also added a regression test in packages/core/src/widgets/__tests__/vnode.prop-validation.test.ts (select measurement uses placeholder width when value is stale) to lock this.
Validation rerun:
- npm run lint
- npm run build
- npm run typecheck
- node scripts/run-tests.mjs (pass: 2694, fail: 0)
Summary
ui.*factory behavior acrosspackages/core/src/widgets/ui.tsui.layers,ui.richText,ui.vstack, andui.hstacknull/false/undefinedselect,slider,checkbox, andradioGroup, and strengthenedbutton.idto non-emptyZRUI_INVALID_PROPSfatals instead of downstream crashespackages/core/src/widgets/__tests__/vnode.factory.test.tspackages/core/src/widgets/__tests__/vnode.children-filter.test.tspackages/core/src/widgets/__tests__/vnode.prop-validation.test.tsWhy
This closes type-safety and runtime-validation gaps in factory construction and interactive widget handling, and adds exhaustive coverage so regressions in factory shape, key forwarding, child normalization, and required-prop enforcement are caught immediately.
Validation
npm run lintnpm run buildnpm run typechecknode scripts/run-tests.mjs(# tests 2693,# pass 2693,# fail 0)