rjsf-team / react-jsonschema-form

A React component for building Web forms from JSON Schema.
https://rjsf-team.github.io/react-jsonschema-form/
Apache License 2.0
14.1k stars 2.18k forks source link

Override field DescriptionField #2219

Closed gaitat closed 2 years ago

gaitat commented 3 years ago

Prerequisites

Description

When I override DescriptionField in core then all works fine. When I override it in material-ui or bootstrap-4 then nothing happens.

Steps to Reproduce

  1. Go to above sample (core is enabled) and observe that all is fine.
  2. Comment lines 27-29 and observe that the description on the schema element disappears. So far so good.
  3. Change import Form from "@rjsf/core"; to import Form from "@rjsf/material-ui"; or import Form from "@rjsf/bootstrap-4";
  4. No matter if lines 27-29 are commented out or not, the description field gets rendered.

Expected behavior

When I override DescriptionField in material-ui or bootstrap-4 and comment out lines 27-29 I expect not to see the description field being rendered.

Actual behavior

The description field is still rendered when material-ui or bootstrap-4 is selected and lines 27-29 are commented out.

What am I doing wrong?

JonSilver commented 3 years ago

I can confirm that a custom DescriptionField supplied to the Form component in the fields prop is ignored and unused in the Bootstrap-4 variant.

aucuparia commented 3 years ago

I don't have a solution, but noticed that it does work when the type is object instead of string. I can reproduce this in @gaitat's sample by adding description: "test", to the "custom fields demo" object and then commenting lines 27-29. This hides the description.

JonSilver commented 3 years ago

Duplicate of #2363

ssbyoung commented 3 years ago

For semantic-ui I've fixed this issue in the following PR: https://github.com/rjsf-team/react-jsonschema-form/pull/2451

Bootstrap and material UI are doing the same thing where they aren't getting the description component from the registry.

heath-freenome commented 2 years ago

Fixed in the v5 beta, see the 5.x migration guide