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

CheckboxGroupInput doesn't display error in red when wrapped in a ReferenceArrayInput #5952

Closed
sylvaindubus opened this issue Feb 24, 2021 · 1 comment · Fixed by #5953
Closed
Labels

Comments

@sylvaindubus
Copy link

What you were expecting:
I am expecting the label and the error message to be in red if there is an an error.

What happened instead:
Both label and error message remain grey, which makes error spotting more complicated.

Steps to reproduce:
Simply wrap a <CheckboxGroupInput> element into a <ReferenceArrayInput> element, as follows:

<ReferenceArrayInput source="roomsIds" resource="RoomOffer" reference="Room" helperText="Test">
  <CheckboxGroupInput label="My label" validate={required()} />
</ReferenceArrayInput>

Here is the problem:
Capture d’écran 2021-02-24 à 10 41 19

Explanations:
It seems the element is passing an error props to all children element. As it is not sanitized in <CheckboxGroupInput> element, it will remains always at null for the <FormControl> element.

Current workaround:
My workaround is to sanitize props passed to <CheckboxGroupInput>, by creating a new component and simply removing the error prop:

const SanitizedCheckboxGroupInput = props => {
  const { error, ...rest } = props
  return <CheckboxGroupInput {...rest} />
}

Environment

  • React-admin version: 3.11.1
  • React version: 17.0.1
  • Browser: any
@djhi
Copy link
Collaborator

djhi commented Feb 24, 2021

Reproduced. Thanks for the report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants