feat(forms): @-mention field tokens + multi-value logic, with review fixes#110
Merged
Conversation
…fixes Field-mention (`@`) tokens in labels/descriptions that resolve to live answers, built on @platejs/mention, plus logic-engine support for multi-value set-values and an `optional` action. Review fixes applied on top: - LabelBody: move the values useStore into a child component so the hook order stays stable when a label's last mention is removed (was a conditional hook that could crash the live preview). - engine: share a single asString coercion with operators.ts instead of a duplicated copy that could drift. - engine: skip the visibility-convergence loop unless a show/hide-toggled field is itself a condition source — one pass is exact otherwise, avoiding O(fields × rules) re-accumulation per keystroke on large forms.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- oxfmt multi-select.tsx (was left unformatted in the prior commit → Format job). - Remove the now-unused useFormIsDark hook (and its orphaned useResolvedTheme import): this feature dropped getMultiSelectColor's isDark argument and the dark chip palette, so form-preview chips render neutral and nothing reads the hook anymore → knip --strict failed the Lint job. Update the stale comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Field-mention (
@) tokens in labels/descriptions that resolve to live answers (built on@platejs/mention), plus logic-engine support for multi-value set-values and anoptionalaction.This branch also applies the fixes from the
/code-reviewpass.Review fixes
LabelBodyconditional hook → crash (correctness).useStorewas called after an early return; removing a label's last@-mention flipslabelNodestoundefined, changing the hook count and crashing the live preview. Moved the subscription into aLabelBodyWithMentionschild that only mounts whenlabelNodes && form, so hook order is always stable. (src/components/form-components/fields/shared.tsx)asStringcoercion (maintainability). The logic engine carried its own copy of the array→string coercion that mirrorsoperators.ts. Exported the canonicalasStringfromoperators.tsand imported it inengine.tsso the two can't drift. (src/lib/logic/engine.ts,src/lib/logic/operators.ts)fields.lengthtimes. It only matters when a show/hide-toggled field is itself a condition source; otherwise masking can't change any outcome. Added that guard so unrelated forms run a single pass. (src/lib/logic/engine.ts)Findings investigated and dismissed
return clearinform-option-item-node.tsxandgetClientRects()[0]inblock-draggable.tsxare both correctly handled (cleanup return /rect ?guard).Verification
pnpm exec tsc --noEmit— cleanvitest runon engine / operators / extract-ruleset / resolve-mentions — 116 passedCI
Initial CI flagged two issues, both now fixed in a follow-up commit:
multi-select.tsxwas left unformatted; ranoxfmt.useFormIsDarkexport. The feature droppedgetMultiSelectColor'sisDarkargument and the dark chip palette (form-preview chips render neutral now), so nothing consumed the hook anymore.