fix: FormItemLayout does not apply item id correctly (#49593)

## Problem

`<FormItemLayout>` does not apply item id correctly. This can be seen on
https://supabase.com/design-system/docs/ui-patterns/forms: open the
devtool and check the form items labels. They have no `for` attribute.
This makes it harder to correctly test and is an accessibility issue.

Axe devtool actually report it

## Solution

When inside React Hook Form, `<FormItemLayout>` actually generate an
`id` (via `<FormItem>`). However, this `id` is overridden in
`<FormLayout>` and read from context by `<FormLabel>`. Simply removing
this line fixes it and correctly binds the label to its input
This commit is contained in:
Gildas Garcia authored and GitHub committed 2026-08-27 09:00:11 +02:00
1 parent 961fc749d4
commit df48528443
1 file changed
-1
@@ -398,7 +398,6 @@ export const FormLayout = React.forwardRef<
<FormLabel
className="text-foreground flex gap-2 items-center wrap-break-word"
data-formlayout-id="formLabel"
htmlFor={props.name || id}
>
<LabelContents />
</FormLabel>