From 6666b181ab548319042ef29a3df098e6da71b66a Mon Sep 17 00:00:00 2001 From: Heath C <51679588+heath-freenome@users.noreply.github.com> Date: Fri, 7 Oct 2022 09:12:13 -0700 Subject: [PATCH] Fix #3174 by not rendering empty help and extra information for fields (#3187) Fixed #3174 - Updated `FieldTemplate` to ensure that `help` and `extra` information is only rendered when the `rawDescription` and `rawErrors` are not provided - Before, even though `description` and `errors` would render empty components, it would still cause unnecessary whitespace in which they were rendered - Now, those props are passed undefined unless the raw information indicates there is data to render - Updated the test snapshots - Updated the `CHANGELOG.md` accordingly --- CHANGELOG.md | 3 ++ .../src/templates/FieldTemplate/index.tsx | 5 +-- .../test/__snapshots__/Array.test.tsx.snap | 31 +++---------------- .../test/__snapshots__/Form.test.tsx.snap | 9 ++---- .../test/__snapshots__/Object.test.tsx.snap | 15 ++------- 5 files changed, 17 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e99f4e39ce..045d73da29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ should change the heading of the (upcoming) version to include a major version b --> # 5.0.0-beta.11 +## @rjsf/antd +- Updated `FieldTemplate` to no longer render additional, unnecessary white space for fields that have empty `help` and `extra` information, fixing [#3147](https://github.com/rjsf-team/react-jsonschema-form/issues/3174) + ## @rjsf/bootstrap-4 - Make label generation consistent with other themes by refactoring the code into the `FieldTemplate` instead of having the widgets implementing the label, fixing [#2007](https://github.com/rjsf-team/react-jsonschema-form/issues/2007) diff --git a/packages/antd/src/templates/FieldTemplate/index.tsx b/packages/antd/src/templates/FieldTemplate/index.tsx index 371d6edd7c..87d8800619 100644 --- a/packages/antd/src/templates/FieldTemplate/index.tsx +++ b/packages/antd/src/templates/FieldTemplate/index.tsx @@ -22,6 +22,7 @@ const FieldTemplate = ({ onDropPropertyClick, onKeyChange, rawErrors, + rawDescription, rawHelp, readonly, registry, @@ -66,9 +67,9 @@ const FieldTemplate = ({ ) : (