Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid cloning elements in forms #7223

Merged
merged 22 commits into from
Feb 16, 2022
Merged

Avoid cloning elements in forms #7223

merged 22 commits into from
Feb 16, 2022

Conversation

djhi
Copy link
Collaborator

@djhi djhi commented Feb 10, 2022

After this PR, I'll make a few others to ensure that every inputs handle the fullWidth property correctly. I'll also add stories for each input.

@djhi djhi added this to the 4.0.0-alpha.3 milestone Feb 10, 2022
UPGRADE.md Show resolved Hide resolved
UPGRADE.md Outdated Show resolved Hide resolved
@@ -818,30 +818,34 @@ export const PostCreate = () => (

### Label Decoration

`<SimpleForm>` scans its children for the `addLabel` prop, and automatically wraps a child in a `<Labeled>` component when found. This displays a label on top of the child, based on the `label` prop. This is not necessary for `<Input>` components, as they already contain their label. Also, all the react-admin `<Field>` components have a default prop `addLabel: true`, which explains why react-admin shows a label on top of Fields when they are used as children of `<SimpleForm>`.
All react-admin inputs handle the display of their label by wrapping their content inside a `<Labeled>` component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not true for Inputs. Fields, maybe?

Copy link
Collaborator Author

@djhi djhi Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually true for many inputs (ArrayInput, CheckboxGroupInput, FileInput, RadioButtonGroupInput, SelectArrayInput and SelectInput). The others uses MUI default label

@@ -969,31 +973,37 @@ export const PostEdit = () => (

### Label Decoration

`<FormTab>` scans its children for the `addLabel` prop, and automatically wraps a child in a `<Labeled>` component when found. This displays a label on top of the child, based on the `label` prop. This is not necessary for `<Input>` components, as they already contain their label. Also, all the react-admin `<Field>` components have a default prop `addLabel: true`, which explains why react-admin shows a label on top of Fields when they are used as children of `<FormTab>`.
All react-admin inputs handle the display of their label by wrapping their content inside a `<Labeled>` component.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this content repeated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this section inside the SimpleForm and the TabbedForm sections

docs/Fields.md Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/form/FormTab.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/input/Labeled.tsx Outdated Show resolved Hide resolved
UPGRADE.md Show resolved Hide resolved

This is no longer the case and makes custom layout easier.

### `<SimpleForm>` and `<TabbedForm>` No Longer Clone Their Children
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, this is wonderful! 💪

docs/Fields.md Outdated Show resolved Hide resolved
docs/Labeled.md Show resolved Hide resolved
docs/Labeled.md Show resolved Hide resolved
docs/SimpleShowLayout.md Outdated Show resolved Hide resolved
docs/TabbedShowLayout.md Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/Labeled.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/Labeled.tsx Outdated Show resolved Hide resolved
docs/Reference.md Show resolved Hide resolved
docs/Fields.md Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/Labeled.tsx Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/defaultTheme.ts Outdated Show resolved Hide resolved
packages/ra-ui-materialui/src/form/FormTab.tsx Outdated Show resolved Hide resolved
@fzaninotto fzaninotto merged commit 59bd997 into next Feb 16, 2022
@fzaninotto fzaninotto deleted the avoid-cloning-forms branch February 16, 2022 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants