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

MUI/material-ui theme's ArrayFieldTemplate renders items in double grid container #3863

Closed
4 tasks done
jroebu14 opened this issue Sep 11, 2023 · 0 comments · Fixed by #3864
Closed
4 tasks done

MUI/material-ui theme's ArrayFieldTemplate renders items in double grid container #3863

jroebu14 opened this issue Sep 11, 2023 · 0 comments · Fixed by #3864
Labels
arrays bug help wanted material-ui material-ui related theme issue

Comments

@jroebu14
Copy link
Contributor

Prerequisites

What theme are you using?

mui

Version

5.x

Current Behavior

For the MUI and material-ui themes, the ArrayFieldTemplate renders the ArrayFieldItemTemplate components inside of a grid container and those components also render a grid container. For custom themes that add default spacing to grid items, this can result in double negative spacing margins on the container which causes the field description text to be obscured.

The current grid structure in ArrayFieldTemplate:

ArrayFieldTemplate > grid-containter > grid-container(ArrayFieldItemTemplate)

Changing the ArrayFieldItemTemplate wrapper to a grid item fixes the issue:

ArrayFieldTemplate > grid-containter > grid-item(ArrayFieldItemTemplate)

Expected Behavior

The grid in ArrayFieldTemplate should be correctly rendered with the structure ArrayFieldTemplate > grid-containter > grid-item(ArrayFieldItemTemplate) so it is not possible for the ArrayFieldItemTemplate to create double negative margins and obscure the field description text.

Steps To Reproduce

  1. Create a form with a schema that renders the ArrayFieldTemplate in a MUI or material-ui theme e.g.
        <Form
          schema={{
            "type": "array",
            "description": "Users who are authorized",
            "title": "Authorized Users",
            "items": [
              {
                "type": "string",
                "default": "user"
              }
            ],
            "additionalItems": {
              "title": "Additional Users",
              "type": "string"
            }
          }}
          validator={validator}
        />
  1. Inspect the array field items wrapping container and notice the double grid container structure

grid-bug

Environment

- OS: Mac 13.5.1
- Node: 18.6.0
- npm: 9.5.1

Anything else?

CodeSandbox: https://codesandbox.io/p/sandbox/festive-benji-jt6tjv?file=/pages/index.tsx:17,34

How a fix would look rendered:
grid-fix

@jroebu14 jroebu14 added bug needs triage Initial label given, to be assigned correct labels and assigned labels Sep 11, 2023
@heath-freenome heath-freenome added help wanted arrays material-ui material-ui related theme issue and removed needs triage Initial label given, to be assigned correct labels and assigned labels Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays bug help wanted material-ui material-ui related theme issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants