Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

Commit 662a0ba

Browse files
committed
refactor(components): draw the field help line with a render function (objectui#12108)
The help line under a field was a module-level `FieldDescription` component, which added a react-refresh/only-export-components warning to form.tsx. It is now `renderFieldDescription`, the shape of `withReadonlyHostGroup` beside it; the DOM it draws is unchanged. Claude-Session: https://claude.ai/code/session_01AswpQDLCKiZos2jCXknwKz Co-authored-by: Claude <noreply@anthropic.com>
1 parent ad59f8b commit 662a0ba

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

  • packages/components/src/renderers/form

‎packages/components/src/renderers/form/form.tsx‎

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ const useSafeFormTranslation = createSafeTranslation(
364364
'form.visibleWhenFaulted':
365365
"Can't submit: the visibleWhen rule of {{fields}} could not be evaluated. The rule must be fixed before this form can be submitted.",
366366
// objectui#12108 — the hint under an empty field the server fills at insert
367-
// (see `FieldDescription`). Byte-identical to the `en` pack.
367+
// (see `renderFieldDescription`). Byte-identical to the `en` pack.
368368
'form.serverDefaultHint': 'Set automatically when saved.',
369369
},
370370
'common.selectOption',
@@ -979,13 +979,10 @@ function withReadonlyHostGroup(labelId: string | undefined, node: React.ReactNod
979979
* widget reads its placeholder off the field metadata, not off the host, and
980980
* the date, time, boolean and user widgets draw none at all.
981981
*/
982-
function FieldDescription({
983-
description,
984-
serverDefaultHint,
985-
}: {
986-
description?: string;
987-
serverDefaultHint?: string;
988-
}): React.ReactElement | null {
982+
function renderFieldDescription(
983+
description: string | undefined,
984+
serverDefaultHint: string | undefined,
985+
): React.ReactNode {
989986
if (!description && !serverDefaultHint) return null;
990987
return (
991988
<FormDescription>
@@ -3539,8 +3536,8 @@ ComponentRegistry.register('form',
35393536
...(groupLabelId ? { 'aria-labelledby': groupLabelId } : null),
35403537
}))}
35413538
</FormControl>
3542-
<FieldDescription
3543-
description={description}
3539+
{renderFieldDescription(
3540+
description,
35443541
// objectui#12108 — shown exactly while the submit would omit
35453542
// the key, so the server fills the field: it is server-owned
35463543
// (`serverOwned`, the classifier the required suppression above
@@ -3554,12 +3551,10 @@ ComponentRegistry.register('form',
35543551
// an empty stored column there is filled by no save. The same
35553552
// gate hides the hint on a locked field of a real create form,
35563553
// which is a missing hint, never a wrong one.
3557-
serverDefaultHint={
3558-
serverOwned && !readonly && !fieldDisabled && isMissingForRequired(formField.value)
3559-
? t('form.serverDefaultHint')
3560-
: undefined
3561-
}
3562-
/>
3554+
serverOwned && !readonly && !fieldDisabled && isMissingForRequired(formField.value)
3555+
? t('form.serverDefaultHint')
3556+
: undefined,
3557+
)}
35633558
<FormMessage />
35643559
</FormItem>
35653560
)}

0 commit comments

Comments
 (0)