Skip to content

Commit cafc0b6

Browse files
committed
Document that nested box fields in FormLayoutCustomField must hide their labels
Adds a "Nested Fields Labels" section to the `FormLayout` README explaining that `TextField`, `TextArea`, `SelectField`, and `FileInputField` nested inside `FormLayoutCustomField` must use `isLabelVisible={false}`, because `FormLayout` forces horizontal layout on all descendants and a visible label would conflict with the grid. Updates the story and tests to follow this rule: removes prop test cases that used visible labels on nested fields, adds `isLabelVisible={false}` to the non-visual tests, and applies the same fix to the story component. Also adds `Button` to the story and renames the `30px` custom label width test case to the more representative `100px`.
1 parent 855bf12 commit cafc0b6

19 files changed

Lines changed: 42 additions & 28 deletions

src/components/FormLayout/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,30 @@ and its styles may affect contained form fields through CSS cascade, don't
330330
forget to mirror the aforementioned properties to the contained form fields too
331331
as API options as such are **not** inherited.
332332

333+
### Nested Fields Labels
334+
335+
When placing box form fields — TextField, TextArea, SelectField, or
336+
FileInputField — inside a FormLayoutCustomField, we recommend to hide their
337+
labels with `isLabelVisible={false}`.
338+
339+
```docoff-react-preview
340+
<FormLayout fieldLayout="horizontal" labelWidth="auto">
341+
<FormLayoutCustomField
342+
innerFieldSize="medium"
343+
label="Custom field with invisible label"
344+
>
345+
<TextField
346+
isLabelVisible={false}
347+
label="This field's label is hidden"
348+
/>
349+
</FormLayoutCustomField>
350+
</FormLayout>
351+
```
352+
353+
ℹ️ Because FormLayout forces horizontal layout on all its descendants, the
354+
nested field's own label would conflict with the FormLayout grid and produce
355+
incorrect alignment.
356+
333357
### Label Alignment
334358

335359
If you are in a situation with one or more box form fields inside your
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)