Skip to content

Commit bed242c

Browse files
committed
fix(ui): AutoForm i18nPrefix — skip description when the dict key is missing
tr() echoes the key back for a missing entry (an empty-string default is falsy, so the provider can't substitute it), so the field description showed the raw key (parameters.x.y.desc). Guard with for both label and description, restoring the schema-derived fallback when no entry exists.
1 parent a77f3fc commit bed242c

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

packages/@alepha/ui/src/components/auto-form/auto-form.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,20 @@ function GroupBlock(props: GroupBlockProps) {
549549
...override,
550550
};
551551
// i18nPrefix: fill label/description from the dictionary when neither
552-
// the override nor the schema already provides one. `default: ""` →
553-
// a missing key yields "" → falsy → the Control falls back to
554-
// `schema.title ?? prettyName(field)`, preserving current behaviour.
552+
// the override nor the schema already provides one. A missing key
553+
// makes `tr` echo the key back (an empty `default` is falsy, so the
554+
// provider can't substitute it) — guard with `!== key` so an absent
555+
// entry leaves the Control to fall back to `schema.title ??
556+
// prettyName(field)`, preserving current behaviour.
555557
if (props.i18nPrefix && merged.label === undefined) {
556-
const label = tr(`${props.i18nPrefix}.${name}`, { default: "" });
557-
if (label) merged.label = label;
558+
const key = `${props.i18nPrefix}.${name}`;
559+
const label = tr(key, { default: "" });
560+
if (label && label !== key) merged.label = label;
558561
}
559562
if (props.i18nPrefix && merged.description === undefined) {
560-
const desc = tr(`${props.i18nPrefix}.${name}.desc`, { default: "" });
561-
if (desc) merged.description = desc;
563+
const key = `${props.i18nPrefix}.${name}.desc`;
564+
const desc = tr(key, { default: "" });
565+
if (desc && desc !== key) merged.description = desc;
562566
}
563567
return { name, input, props: merged };
564568
})

0 commit comments

Comments
 (0)