fix(ui): render DateTime label as <label> instead of <span> (#12949)
## What / Why Date & Time fields were rendering their field label as a `<span>` while every other field type uses a proper `<label>` with a matching `htmlFor`. Because the element was a span it broke styles and made 'field-label' have different styles from the rest of 'field-label's. **Root cause:** DateTimeField failed to pass its `path` (or an explicit `htmlFor`) to `FieldLabel`. When `FieldLabel` receives no `htmlFor`, it intentionally downgrades to a `<span>`. ## Screenshots ### Before  *DateTime label rendered as `<span>`, causing style inconsistencies* ### After  *DateTime label now rendered as proper `<label>` element* ## Changes introduced - `packages/ui/src/fields/DateTime/index.tsx` - Added `path={path}` prop to `FieldLabel` component ## Behavior after the fix - Date-time labels are now real `<label>` elements with `for="field-…"` - Visual alignment now matches every other field type ## How to test manually 1. Run `pnpm dev fields` 2. Inspect the DateTime field markup – label is now `<label>` 3. Observe that vertical spacing matches other types of fields
This commit is contained in:
@@ -167,7 +167,9 @@ const DateTimeFieldComponent: DateFieldClientComponent = (props) => {
|
|||||||
>
|
>
|
||||||
<RenderCustomComponent
|
<RenderCustomComponent
|
||||||
CustomComponent={Label}
|
CustomComponent={Label}
|
||||||
Fallback={<FieldLabel label={label} localized={localized} required={required} />}
|
Fallback={
|
||||||
|
<FieldLabel label={label} localized={localized} path={path} required={required} />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<div className={`${fieldBaseClass}__wrap`} id={`field-${path.replace(/\./g, '__')}`}>
|
<div className={`${fieldBaseClass}__wrap`} id={`field-${path.replace(/\./g, '__')}`}>
|
||||||
<RenderCustomComponent
|
<RenderCustomComponent
|
||||||
|
|||||||
Reference in New Issue
Block a user