Skip to content

Commit 55020c3

Browse files
fix(form): recompute formula fields from the live inputs before judging field rules (#35116)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8VjQGdf4i6Ff5bzwJcTFarg)_ Fixes #35033 Clause-②: yes (widening) — one new member on the `@object-ui/core` package entry (the client formula pass, `ui/packages/core/src/evaluator/formulaRecord.ts`), nothing removed or renamed Metadata-protocol: none ## 维护者速读 - 改了什么:表单在判 `visibleWhen` / `requiredWhen` / `readonlyWhen` 之前,先用页面上正在输入的值把对象的公式字段算一遍(对象表单渲染器 + 控制台表单视图页 FormPage 两处),`@object-ui/core` 多导出一个 `planObjectFormulas`。 - 为什么改:必填字段的 `visibleWhen` 读公式时,新建表单怎么填都不显示(公式没画在表单上时还会整单拒绝提交),编辑跨过条件也不显示,而服务端按算出来的值要求必填——用户无法保存。 - 风险与回滚:只影响声明了字段规则、且对象有公式字段的表单;算不出的公式(跨引用、`label()`、`current_user` 等)一律按"显示且必填、不拒绝提交"处理,与服务端一致。回滚即 revert 本 PR。 - 先看:`ui/packages/core/src/evaluator/formulaRecord.ts`(`planObjectFormulas` 的可算/不可算分类与读序)、`ui/packages/components/src/renderers/form/form.tsx`(`ruleRecord` 末行与 `fields` memo)、`ui/apps/console/src/components/FormPage.tsx`(`ruleValues` 只进规则判定,提交载荷仍是 `values`)。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/components/src/renderers/form/__tests__/form-formula-recompute-35033.test.tsx`,预期 5 passed。 - 需要你做的:无,席位落地(发版冻结期间保持 draft)。 ## What changes - `@object-ui/core`: new `planObjectFormulas(fields)` (exported from the package entry, with its `ObjectFormulaPlan` type). It plans the served object's `formula` fields once and computes them over a record in the platform's read order (`formulaReadOrder`), with the canonical `ExpressionEngine`, as objectql's `formulaValuesFor` does on the server: - **A fault a read shares** (an operator over an empty operand, an undeclared key, a cycle, a traversal conflict): the formula reads `null`, and the rule is judged on that `null`. - **Unservable**: the formula reads through a reference, calls `label()`, reads a scope root other than `record` (so `current_user.can()` too), is served without its expression (an FLS mask), or reads such a formula at any depth. `unservableReadsOf(pred)` names them. - Object form renderer (`form.tsx`): reads the object's formulas through `dataSource.getObjectSchema`, by the route `usePatchingUpdateActions` already uses, and only when some field declares a rule (`objectFormulas.ts`). `ruleRecord` = the formulas computed over (null seed, then last-read record, then live values). A field row whose `visibleWhen` reads an unservable formula loses that `visibleWhen`, with one `console.warn`. The field is shown, keeps its `required`, and is no ADR-0137 D2 submit refusal: this is the server's answer for that predicate under ruling record 6956761249 item 3, and the client is never stricter than the server (ADR-0124). The update-action outcome records are recomputed after their patch too. - Console form-view page (`FormPage.tsx`): the same pass. It was measured as a live create/edit renderer (`/forms/:name`, `?recordId=`, `/f/:slug`) that judges the object-level `visibleWhen` over its own `values`, with the object's fields in hand from `/meta/object`. Only the object-level `rules.visibleWhen` is dropped for an unservable read; the view-level predicate is a layout gate and is left as is. The write payload stays `values`, so a computed formula is never sent. ## Tests - `ui/packages/core/src/evaluator/__tests__/formulaRecord-35033.test.ts`: 10 pins on the pass (read order, no mutation, empty operand → null, cycle → null, hop and its closure unservable, `label()` / `current_user` / masked expression unservable, unnameable predicate reads, and the rule verdicts over the computed record). - `ui/packages/components/src/renderers/form/__tests__/form-formula-recompute-35033.test.tsx`: 5 pins on the real `form` renderer: create crossing, edit crossing, reverse edit, hop → shown + required + submit allowed once filled, empty operand → judged on `null` with no submit refusal. - `ui/apps/console/src/components/FormPage.conditionalRules.test.tsx`: a new top-level `describe` in this harness, holding the same pins for FormPage (create, edit crossing and reverse, hop, empty operand). - `form-required-for-action-28382.test.tsx` "does not read or note anything on a create form": the create form now makes exactly one object read, and it is the formula pass's, so the assertion is now `toHaveBeenCalledTimes(1)`. The note's absence is unchanged. ### Ablation (each leg through `scripts/ablation-replace.mjs`: anchor x1 → x0, blob changed, restored to the HEAD blob; `git diff HEAD` empty afterwards) | Leg | Mutation | Red | Green | |---|---|---|---| | form M1 | `ruleRecord`: `return formulaPlan ? formulaPlan.compute(out) : out;` → `return out;` | create crossing, edit crossing, reverse edit, empty operand (4/5) | hop (needs M2) | | form M2 | `fields`: `withoutUnservableVisibleWhen(...)` → `declaredFields` | hop (1/5) | the other 4 | | FormPage M1 | `ruleValues`: `formulaPlan ? formulaPlan.compute(values) : values` → `values` | create, edit crossing+reverse, empty operand (3/4) | hop (needs M2) | | FormPage M2 | `sections`: `withoutUnservableRuleVisibleWhen(buildSections(...))` → `buildSections(...)` | hop (1/4) | the other 3 | The ablations edit sources that the tests import directly (relative imports), so no `dist/` is involved. ## Acceptance notes - Premise measured on `origin/main` 526282e with the real renderer (throwaway tests, not committed): create with the formula drawn on the form → the required field stays hidden after crossing; create with the formula not drawn → the rule faults on the missing key, the field shows, and every submit is refused ("Can't submit: the visibleWhen rule of Discount note could not be evaluated."); edit crossing → stays hidden. - The client's unservable set is the server's plus the roots the form does not bind for a formula (`current_user`, `os`, `previous`, …). Such a formula is shown, never hidden, so the form cannot be stricter than the server. - `today()` / `now()` formulas are computed with the browser clock and no timezone; the server uses the request's execution context. Near a day boundary the two can disagree. This is noted, not changed. - On the server, field `requiredWhen` / `readonlyWhen` are judged over the merged record without computing formulas (`formulaValues` feeds only the required-when-shown `visibleWhen` on PR #34978's head). This was read, not reproduced. ## Verification <details><summary>Local runs on head 6334ae4</summary> - core helper pins: Tests 10 passed (10) - form renderer pins: Tests 5 passed (5) - FormPage harness file: Tests 29 passed (29) - `packages/core/src/evaluator/`, `packages/components/src/renderers/form/`, `apps/console/src/components/FormPage*`: 157/158 files before the 28382 pin update (the one red was that pin), and the pin file is 14/14 after it - every ui test that counts `getObjectSchema` reads (40 files): Test Files 40 passed (40), Tests 486 passed (486) - `@object-ui/core` and `@object-ui/components` type-check: exit 0. The console type-check needs the whole console closure built, so it is declared to CI (Type Check UI) - eslint on the changed files: 0 errors - overlap-check: VERDICT clean exit 0 </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbWoeMbVAavTXkbV2Cn --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 7ed18b5 commit 55020c3

10 files changed

Lines changed: 1221 additions & 17 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/core': patch
3+
'@object-ui/components': patch
4+
'@object-ui/console': patch
5+
---
6+
7+
fix(form): formula fields are recomputed from the live inputs before the field rules are judged
8+
9+
Clause-②: yes (widening) — one new member on the `@object-ui/core` package entry, `planObjectFormulas` (with its `ObjectFormulaPlan` type); nothing removed or renamed
10+
Metadata-protocol: none
11+
12+
A required field whose `visibleWhen` reads a `formula` field was judged on the formula value the form last read, or on nothing on a create. On a create form the field stayed hidden whatever was typed, or, when the formula was not drawn on the form, the rule faulted on the missing key and every submit was refused. On an edit that moved the inputs across the condition, the field stayed hidden while the server required it. In both cases the user could not save.
13+
14+
The object form renderer and the console's form-view page now compute the object's formula fields over the record being edited, in the platform's read order, with the canonical `@objectstack/formula` engine, and judge `visibleWhen`, `requiredWhen` and `readonlyWhen` over that record. The formulas are computed for the signed-in user as the server computes them: `current_user` (also `user` and `ctx.user`) carries the user's id and positions. A formula that faults the way a read faults (an operator over an empty operand, an undeclared key, a cycle, a scope root the server does not bind for a formula, such as `previous`) reads `null`, and the rule is judged on that `null`. A formula the form cannot compute is one that reads through a reference, calls `label()` or `current_user.can()`, reads `os`, reads the user when nobody is signed in, is served without its expression, or reads such a formula. A field whose `visibleWhen` reads one is shown and keeps its `required` flag, with one console warning, and the form does not refuse the submit for that rule; the server, which judges the write, decides. Computed values are used for the rules only and are never sent in the write.

‎ui/apps/console/src/components/FormPage.conditionalRules.test.tsx‎

Lines changed: 135 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
4040
import { cleanup, render, screen, waitFor } from '@testing-library/react';
4141
import userEvent from '@testing-library/user-event';
4242
import { MemoryRouter, Route, Routes } from 'react-router-dom';
43+
import { PredicateScopeProvider } from '@object-ui/react';
4344
import { buildSections, FormPage, isSectionVisible, resolveRowState } from './FormPage';
4445

4546
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
@@ -124,6 +125,8 @@ interface RenderOpts {
124125
objectSchema?: unknown;
125126
query?: string;
126127
extraRoutes?: Parameters<typeof stubFetch>[0];
128+
/** The ambient predicate scope (`current_user`, …) the host would publish. */
129+
scope?: Record<string, unknown>;
127130
}
128131

129132
/** Render the INTERNAL route (`/forms/:name`) over a given section list. */
@@ -136,7 +139,7 @@ function renderInternal(sections: unknown[], opts: RenderOpts = {}) {
136139
...(opts.extraRoutes ?? []),
137140
]),
138141
);
139-
return render(
142+
const page = (
140143
<MemoryRouter initialEntries={[`/forms/showcase_task.edit${opts.query ?? ''}`]}>
141144
<Routes>
142145
<Route path="/forms/:name" element={<FormPage mode="internal" recordPath={recordPath} />} />
@@ -145,8 +148,9 @@ function renderInternal(sections: unknown[], opts: RenderOpts = {}) {
145148
element={<div data-testid="record-page">record page</div>}
146149
/>
147150
</Routes>
148-
</MemoryRouter>,
151+
</MemoryRouter>
149152
);
153+
return render(opts.scope ? <PredicateScopeProvider scope={opts.scope}>{page}</PredicateScopeProvider> : page);
150154
}
151155

152156
/** Render the PUBLIC route (`/f/:slug`) over a given section list. */
@@ -770,3 +774,132 @@ describe('objectstack#30220 — FormPage judges requiredWhen on an Edit as a tra
770774
expect(writes()).toHaveLength(0);
771775
});
772776
});
777+
778+
/**
779+
* objectstack#35033 — this renderer recomputes the object's `formula` fields
780+
* from the live values before it judges the field rules, so a required field
781+
* whose object-level `visibleWhen` reads a formula is shown (and required)
782+
* exactly when the server would require it. A formula it cannot compute (a
783+
* read through a reference) leaves the field shown and required, with no
784+
* submit refusal for the rule: the server's answer for the same predicate.
785+
*/
786+
describe('objectstack#35033 — FormPage judges a visibleWhen that reads a formula on the recomputed value', () => {
787+
const ESCALATION = {
788+
...BASE_SCHEMA,
789+
fields: {
790+
...BASE_SCHEMA.fields,
791+
account: { type: 'lookup', label: 'Account', reference: 'account' },
792+
escalated: { type: 'formula', label: 'Escalated', expression: "record.priority == 'urgent'" },
793+
long_title: { type: 'formula', label: 'Long title', expression: 'size(record.title) > 3' },
794+
tier: { type: 'formula', label: 'Tier', expression: 'record.account.tier' },
795+
notes: { type: 'text', label: 'Notes', required: true, visibleWhen: 'record.escalated == true' },
796+
} as Record<string, Record<string, unknown>>,
797+
};
798+
const withNotesWhen = (visibleWhen: string) => ({
799+
...ESCALATION,
800+
fields: { ...ESCALATION.fields, notes: { ...ESCALATION.fields.notes, visibleWhen } },
801+
});
802+
const SECTIONS = [{ label: 'Basics', fields: ['priority', 'title', 'notes'] }];
803+
const writes = () => calls.filter((c) => c.method === 'POST' || c.method === 'PATCH');
804+
const editRoutes = (stored: Record<string, unknown>) => [
805+
{ match: '/data/showcase_task/t-1', body: { object: 'showcase_task', id: 't-1', record: { id: 't-1', ...stored } } },
806+
{ method: 'PATCH', match: '/data/showcase_task/t-1', body: { object: 'showcase_task', id: 't-1', record: { id: 't-1' } } },
807+
];
808+
const createRoutes = [{ method: 'POST', match: '/data/showcase_task', body: { object: 'showcase_task', id: 'new-1' } }];
809+
810+
it('create: hidden until the inputs make the formula satisfy it, then shown and required, and the formula is never written', async () => {
811+
const user = userEvent.setup();
812+
const { container } = renderInternal(SECTIONS, { objectSchema: ESCALATION, extraRoutes: createRoutes });
813+
await awaitForm();
814+
expect(screen.queryByLabelText(/^Notes/)).not.toBeInTheDocument();
815+
816+
await user.clear(screen.getByLabelText('Priority'));
817+
await user.type(screen.getByLabelText('Priority'), 'urgent');
818+
await waitFor(() => expect(controlFor(container, 'notes')).toBeRequired());
819+
820+
await user.click(screen.getByRole('button', { name: /submit/i }));
821+
expect(writes()).toHaveLength(0);
822+
823+
await user.type(screen.getByLabelText(/^Notes/), 'paged on-call');
824+
await user.click(screen.getByRole('button', { name: /submit/i }));
825+
await waitFor(() => expect(writes()).toHaveLength(1));
826+
const body = writes()[0].body as Record<string, unknown>;
827+
expect(body.notes).toBe('paged on-call');
828+
expect(body).not.toHaveProperty('escalated');
829+
});
830+
831+
it('edit: a served value outside the condition is recomputed when the inputs cross it, and the reverse edit hides it', async () => {
832+
const user = userEvent.setup();
833+
const { container } = renderInternal(SECTIONS, {
834+
objectSchema: ESCALATION,
835+
query: '?recordId=t-1',
836+
extraRoutes: editRoutes({ priority: 'low', title: 'Old', escalated: false }),
837+
});
838+
await awaitForm();
839+
expect(screen.queryByLabelText(/^Notes/)).not.toBeInTheDocument();
840+
841+
await user.clear(screen.getByLabelText('Priority'));
842+
await user.type(screen.getByLabelText('Priority'), 'urgent');
843+
await waitFor(() => expect(controlFor(container, 'notes')).toBeRequired());
844+
845+
await user.clear(screen.getByLabelText('Priority'));
846+
await user.type(screen.getByLabelText('Priority'), 'low');
847+
await waitFor(() => expect(screen.queryByLabelText(/^Notes/)).not.toBeInTheDocument());
848+
});
849+
850+
it('a formula reading through a reference: shown, required, and the submit goes through once it is filled', async () => {
851+
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
852+
const user = userEvent.setup();
853+
const { container } = renderInternal(SECTIONS, {
854+
objectSchema: withNotesWhen("record.tier == 'gold'"),
855+
extraRoutes: createRoutes,
856+
});
857+
await awaitForm();
858+
expect(controlFor(container, 'notes')).toBeRequired();
859+
expect(warn.mock.calls.some(([m]) => /visibleWhen of field 'notes' reads a formula the form cannot compute/.test(String(m)))).toBe(true);
860+
861+
await user.click(screen.getByRole('button', { name: /submit/i }));
862+
expect(writes()).toHaveLength(0);
863+
expect(screen.queryByText(/could not be evaluated/)).not.toBeInTheDocument();
864+
865+
await user.type(screen.getByLabelText(/^Notes/), 'gold desk');
866+
await user.click(screen.getByRole('button', { name: /submit/i }));
867+
await waitFor(() => expect(writes()).toHaveLength(1));
868+
});
869+
870+
it('a formula reading current_user.id is computed for the acting user of the predicate scope, and the field is judged on it', async () => {
871+
const user = userEvent.setup();
872+
const schema = {
873+
...ESCALATION,
874+
fields: {
875+
...ESCALATION.fields,
876+
owner: { type: 'text', label: 'Owner' },
877+
mine: { type: 'formula', label: 'Mine', expression: 'record.owner == current_user.id' },
878+
notes: { ...ESCALATION.fields.notes, visibleWhen: 'record.mine == true' },
879+
},
880+
};
881+
const { container } = renderInternal([{ label: 'Basics', fields: ['priority', 'owner', 'notes'] }], {
882+
objectSchema: schema,
883+
extraRoutes: createRoutes,
884+
scope: { current_user: { id: 'u1', name: 'Ada', positions: [] } },
885+
});
886+
await awaitForm();
887+
await user.type(screen.getByLabelText('Owner'), 'u2');
888+
// Cleanly not TRUE: hidden.
889+
expect(screen.queryByLabelText(/^Notes/)).not.toBeInTheDocument();
890+
891+
await user.clear(screen.getByLabelText('Owner'));
892+
await user.type(screen.getByLabelText('Owner'), 'u1');
893+
await waitFor(() => expect(controlFor(container, 'notes')).toBeRequired());
894+
});
895+
896+
it('an empty operand reads null, the predicate is judged on it, and the submit is not refused', async () => {
897+
const user = userEvent.setup();
898+
renderInternal(SECTIONS, { objectSchema: withNotesWhen('record.long_title == true'), extraRoutes: createRoutes });
899+
await awaitForm();
900+
expect(screen.queryByLabelText(/^Notes/)).not.toBeInTheDocument();
901+
902+
await user.click(screen.getByRole('button', { name: /submit/i }));
903+
await waitFor(() => expect(writes()).toHaveLength(1));
904+
});
905+
});

‎ui/apps/console/src/components/FormPage.tsx‎

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ import {
126126
isMissingForRequired,
127127
isRuntimeDefault,
128128
isServerOwnedValue,
129+
planObjectFormulas,
129130
resolveAffordance,
130131
resolveFieldRuleState,
131132
type FieldRuleFaults,
133+
type ObjectFormulaPlan,
132134
type FieldRulePredicate,
133135
} from '@object-ui/core';
134136
import { usePermissions } from '@object-ui/permissions';
@@ -2424,6 +2426,50 @@ function findSubmitRefusals(
24242426
return { faultedVisibleWhen, missing };
24252427
}
24262428

2429+
const warnedUnservableRules = new Set<string>();
2430+
2431+
/**
2432+
* `sections` with the OBJECT-level `visibleWhen` (`rules.visibleWhen`) of every
2433+
* row that reads a formula this page cannot compute dropped, each drop warned
2434+
* once (objectstack#35033). The field is then shown and keeps its `required`,
2435+
* and its rule is no fault, so the submit is not refused for it (no ADR-0137
2436+
* D2 refusal) and the server, which judges the write, decides. The view-level
2437+
* predicate is a layout gate and is left alone. Returns `sections` itself when
2438+
* nothing drops.
2439+
*/
2440+
export function withoutUnservableRuleVisibleWhen(
2441+
sections: RenderableSection[],
2442+
plan: ObjectFormulaPlan | undefined,
2443+
): RenderableSection[] {
2444+
if (!plan || plan.unservable.size === 0) return sections;
2445+
let changed = false;
2446+
const out = sections.map((sec) => {
2447+
let fields: RenderableField[] | undefined;
2448+
sec.fields.forEach((f, i) => {
2449+
const pred = f.rules?.visibleWhen;
2450+
if (pred == null) return;
2451+
const reads = plan.unservableReadsOf(pred);
2452+
if (reads.length === 0) return;
2453+
fields ??= sec.fields.slice();
2454+
const { visibleWhen: _dropped, ...rules } = f.rules!;
2455+
fields[i] = { ...f, rules };
2456+
const why = reads.map(([name, reason]) => `'${name}' ${reason}`).join('; ');
2457+
const key = JSON.stringify([f.name, why]);
2458+
if (!warnedUnservableRules.has(key)) {
2459+
warnedUnservableRules.add(key);
2460+
console.warn(
2461+
`[object-ui] The visibleWhen of field '${f.name}' reads a formula the form cannot compute ` +
2462+
`(${why}), so the field is shown and keeps its required flag; the server decides on save.`,
2463+
);
2464+
}
2465+
});
2466+
if (!fields) return sec;
2467+
changed = true;
2468+
return { ...sec, fields };
2469+
});
2470+
return changed ? out : sections;
2471+
}
2472+
24272473
// ─── Main component ─────────────────────────────────────────────────
24282474

24292475
export interface FormPageProps {
@@ -2749,9 +2795,30 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
27492795
// eslint-disable-next-line react-hooks/exhaustive-deps
27502796
}, [mode, identifier, search, channel]);
27512797

2798+
/**
2799+
* The object's `formula` fields, recomputed from the live values for the
2800+
* field rules (objectstack#35033): a rule reading one is judged on the value
2801+
* the written record would serve, as the server judges it. A row whose
2802+
* object-level `visibleWhen` reads a formula this page cannot compute loses
2803+
* that rule — shown and still required, never a submit refusal — in
2804+
* {@link withoutUnservableRuleVisibleWhen}. The payload stays `values`.
2805+
* The formulas are computed for the acting user of `predicateScope`
2806+
* (`current_user`), bound as the server binds it.
2807+
*/
2808+
const formulaPlan = useMemo(
2809+
() => planObjectFormulas(loaded?.objectSchema?.fields, predicateScope),
2810+
[loaded, predicateScope],
2811+
);
2812+
const ruleValues = useMemo(
2813+
() => (formulaPlan ? formulaPlan.compute(values) : values),
2814+
[formulaPlan, values],
2815+
);
27522816
const sections = useMemo<RenderableSection[]>(
2753-
() => (loaded ? buildSections(loaded.form, loaded.objectSchema, language) : []),
2754-
[loaded, language],
2817+
() =>
2818+
loaded
2819+
? withoutUnservableRuleVisibleWhen(buildSections(loaded.form, loaded.objectSchema, language), formulaPlan)
2820+
: [],
2821+
[loaded, language, formulaPlan],
27552822
);
27562823

27572824
/**
@@ -2916,7 +2983,7 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
29162983
const handleWizardNext = (object: string) => {
29172984
const refusals = findSubmitRefusals(
29182985
[sections[currentStep]],
2919-
values,
2986+
ruleValues,
29202987
loaded?.record,
29212988
isCreateForm,
29222989
predicateScope,
@@ -2947,7 +3014,7 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
29473014
if (!loaded) return;
29483015
const refusals = findSubmitRefusals(
29493016
wizardView && !onLastStep ? [sections[currentStep]] : sections,
2950-
values,
3017+
ruleValues,
29513018
loaded.record,
29523019
isCreateForm,
29533020
predicateScope,
@@ -2971,7 +3038,7 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
29713038
}
29723039
const refusals = findSubmitRefusals(
29733040
sections,
2974-
values,
3041+
ruleValues,
29753042
loaded.record,
29763043
isCreateForm,
29773044
predicateScope,
@@ -3288,7 +3355,7 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
32883355
// things that depend on it below — the row's presence, the
32893356
// required marker, and the control's own attributes. Computing
32903357
// it three times would be three chances to disagree.
3291-
const state = resolveRowState(f, values, loaded.record, isCreateForm, predicateScope);
3358+
const state = resolveRowState(f, ruleValues, loaded.record, isCreateForm, predicateScope);
32923359
if (!state.visible) return null;
32933360
// The row's refusal mark, if the last submit left one: its own text
32943361
// under the control, or the banner that names it.
@@ -3386,7 +3453,7 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
33863453
const renderTabbedSections = () => {
33873454
const drawn = sections
33883455
.map((sec, at) => ({ sec, at, key: sectionTabKey(sec, at) }))
3389-
.filter(({ sec }) => isSectionVisible(sec, values, loaded.record, predicateScope));
3456+
.filter(({ sec }) => isSectionVisible(sec, ruleValues, loaded.record, predicateScope));
33903457
if (drawn.length === 0) return null;
33913458
const active = resolveActiveTab(drawn.map((d) => d.key), pickedTab, loaded.form?.defaultTab);
33923459
const stripAt = loaded.form?.tabPosition ?? 'top';
@@ -3577,7 +3644,7 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
35773644
// would renumber every later section the moment one hid, remounting
35783645
// their inputs and taking the caret with them. `null` keeps each
35793646
// surviving section on the key it already had.
3580-
if (!isSectionVisible(sec, values, loaded.record, predicateScope)) return null;
3647+
if (!isSectionVisible(sec, ruleValues, loaded.record, predicateScope)) return null;
35813648
return (
35823649
<section key={i} className="rounded-md border bg-card p-4 sm:p-5">
35833650
{sec.label && (

0 commit comments

Comments
 (0)