feat(forms): B2 conditional rules in grids (row-scoped) + requiredWhen submit enforcement#1579
Merged
Merged
Conversation
…n submit enforcement A-series follow-ups to B2: - GridField evaluates a column's readonlyWhen/requiredWhen per row via resolveFieldRuleState; deriveMasterDetail carries the props onto the column. A readonlyWhen-TRUE cell locks; a requiredWhen-TRUE empty cell flags inline-invalid. Rules are row-scoped (record.*); core gains an optional `scope` + GridField a `contextRecord` prop so a future header-driven lock can bind `parent.*` (deferred — needs the master-detail header's re-renders isolated from the grid). - Submit enforcement: requiredWhen already drove RHF's `required` rule (submit blocked + field error). Added a reactive cleanup that clears a stale required error when the predicate flips FALSE, and clears all errors for a field hidden by visibleWhen. - Tests: core scope unit test (18), deriveMasterDetail rule-copy test (25), live e2e grid-conditional-rules + required-when-submit. Full live suite 13/13. - ADR-0036 amended (grids + submit-time enforcement + deferred parent scope). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
What
Follow-ups to B2 (field conditional rules), the low-cost "wrap-up" set:
A1 — rules in inline line-item grids (row-scoped)
A grid column's
readonlyWhen/requiredWhenCEL rule is now honored per row:deriveMasterDetailcarries the props onto theGridColumn, andGridFieldevaluates them against each row viaresolveFieldRuleState. AreadonlyWhen-TRUE cell locks; arequiredWhen-TRUE empty cell flags inline-invalid.Rules are row-scoped (
record.*) today — e.g.description.requiredWhen = "record.quantity >= 100". The core helpers gained an optionalscope(andGridFieldacontextRecordprop) so a future header-driven lock can bindparent.*(e.g. "paid invoice → lock lines"). That wiring is deferred: feeding the live header record into the grid requires isolating the grid's re-renders from the master-detail header form, whoseform.resetis sensitive to mid-submit re-renders (a regression I hit and backed out — see ADR-0036).A2 —
requiredWhensubmit-time enforcementrequiredWhenalready drove react-hook-form'srequiredrule, so saving while the predicate is TRUE and the value is empty blocks submit with a field error. Added a reactive cleanup so a stale required error clears when the predicate flips FALSE (RHF keeps an error until the field itself revalidates), and all errors clear when a field is hidden byvisibleWhen.Tests
scope/parentunit test (18 total).deriveColumnsrule-copy test (25 total); suite 98/98.grid-conditional-rules(row-scoped required flag) +required-when-submit(blocked + error, relaxes when FALSE). Full live suite 13/13.Showcase rule lives in a framework PR.
🤖 Generated with Claude Code