Skip to content

Commit 341bfb5

Browse files
os-zhuangclaude
andauthored
fix: read spec-canonical keys for dashboard header title and field length rules (#2806)
Naming-drift closeouts (framework#1878 / framework#1891): - DashboardRenderer header falls back to spec-canonical `label` when the legacy `title` is absent (mirrors DashboardGridLayout, #2666). - Field validation rules read spec-canonical camelCase minLength/maxLength (what the server record-validator enforces), snake_case kept as fallback. Claude-Session: https://claude.ai/code/session_01CMaDBhnZEUu1fcw8Rvo6Yq Co-authored-by: Claude <noreply@anthropic.com>
1 parent ba73a02 commit 341bfb5

3 files changed

Lines changed: 34 additions & 8 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@object-ui/plugin-dashboard": patch
3+
"@object-ui/fields": patch
4+
---
5+
6+
fix: read spec-canonical keys for dashboard header title and field length rules
7+
8+
Two naming-drift closeouts (framework#1878 / framework#1891):
9+
10+
- `DashboardRenderer` header now falls back to the spec-canonical `label` when
11+
the legacy `title` is absent (mirrors the `DashboardGridLayout` fallback from
12+
#2666) — a spec-compliant dashboard gets its header title.
13+
- Field validation rules now read the spec-canonical camelCase
14+
`minLength`/`maxLength` (what the server record-validator enforces) with the
15+
legacy snake_case `min_length`/`max_length` kept as fallback — authored
16+
length constraints reach the client form.

packages/fields/src/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,18 +1966,23 @@ export function buildValidationRules(field: any): any {
19661966
// vars); a field-authored `*_message` is a string and passes through as-is,
19671967
// still winning over the localized default. See form.tsx `localizeRule`.
19681968

1969-
// Length validation for text fields
1970-
if (field.min_length) {
1969+
// Length validation for text fields. The spec-canonical keys are camelCase
1970+
// (`minLength`/`maxLength`, @objectstack/spec FieldSchema — what the server
1971+
// record-validator enforces); the snake_case pair is the legacy objectui
1972+
// spelling, kept as fallback (framework#1878/#1891 naming-drift closeout).
1973+
const minLength = (field as any).minLength ?? field.min_length;
1974+
if (minLength) {
19711975
rules.minLength = {
1972-
value: field.min_length,
1976+
value: minLength,
19731977
message: typeof field.min_length_message === 'string' ? field.min_length_message : undefined,
19741978
messageKey: 'validation.minLength',
19751979
};
19761980
}
19771981

1978-
if (field.max_length) {
1982+
const maxLength = (field as any).maxLength ?? field.max_length;
1983+
if (maxLength) {
19791984
rules.maxLength = {
1980-
value: field.max_length,
1985+
value: maxLength,
19811986
message: typeof field.max_length_message === 'string' ? field.max_length_message : undefined,
19821987
messageKey: 'validation.maxLength',
19831988
};

packages/plugin-dashboard/src/DashboardRenderer.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,13 +775,18 @@ const DashboardRendererInner = forwardRef<HTMLDivElement, DashboardRendererProps
775775
return <Fragment key={widgetKey}>{renderedNode}</Fragment>;
776776
};
777777

778+
// The spec-canonical dashboard display name is `label` (@objectstack/spec
779+
// DashboardSchema); `title` is the legacy objectui spelling. Read both so
780+
// spec-compliant dashboards get their header title (framework#1878/#1891;
781+
// mirrors the DashboardGridLayout fallback from #2666).
782+
const headerTitle = schema.title || schema.label;
778783
const headerSection = schema.header && (
779784
<div className="col-span-full mb-4">
780-
{!hideHeaderText && schema.header.showTitle !== false && schema.title && (
785+
{!hideHeaderText && schema.header.showTitle !== false && headerTitle && (
781786
<h2 className="text-lg font-semibold tracking-tight">
782787
{dashName
783-
? dashboardLabel({ name: dashName, label: resolveLabel(schema.title) })
784-
: resolveLabel(schema.title)}
788+
? dashboardLabel({ name: dashName, label: resolveLabel(headerTitle) })
789+
: resolveLabel(headerTitle)}
785790
</h2>
786791
)}
787792
{!hideHeaderText && schema.header.showDescription !== false && schema.description && (

0 commit comments

Comments
 (0)