From 745781084a1bbbd619aad318b32452c519e96c13 Mon Sep 17 00:00:00 2001 From: Heath Chiavettone Date: Mon, 8 Jan 2024 14:32:25 -0800 Subject: [PATCH] Fix: Change FormHelperText usage with @mui/material to render divs Fixes #4031 by switching the render component for `FormHelperText` to be `div` - In `@rjsf/mui`, updated `FieldErrorTemplate` and `FieldHelpTemplate` to use the `div` component for `FormHelperText` --- CHANGELOG.md | 6 +++++- .../mui/src/FieldErrorTemplate/FieldErrorTemplate.tsx | 6 ++++-- .../mui/src/FieldHelpTemplate/FieldHelpTemplate.tsx | 6 +++++- packages/mui/test/__snapshots__/Array.test.tsx.snap | 7 ++++--- packages/mui/test/__snapshots__/Form.test.tsx.snap | 11 ++++++----- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b40d19b7a..77d4a526b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ it according to semantic versioning. For example, if your PR adds a breaking cha should change the heading of the (upcoming) version to include a major version bump. --> -# 5.15.3 +# 5.16.0 ## @rjsf/utils @@ -34,6 +34,10 @@ should change the heading of the (upcoming) version to include a major version b - Removed `dateElementProps` function implementation, and replaced it with `getDateElementProps` from `@rjsf/utils`. +## @rjsf/mui + +- Fixed the `FieldErrorTemplate` and `FieldHelpTemplate` to support html-based errors that cause ` cannot appear as a descendant of

` browser warnings, fixing [#4031](https://github.com/rjsf-team/react-jsonschema-form/issues/4031) + ## Dev / docs / playground - Updated docs and playground with the implementation guide of newly added date re-order feature. diff --git a/packages/mui/src/FieldErrorTemplate/FieldErrorTemplate.tsx b/packages/mui/src/FieldErrorTemplate/FieldErrorTemplate.tsx index 12c11ae498..792b40c66c 100644 --- a/packages/mui/src/FieldErrorTemplate/FieldErrorTemplate.tsx +++ b/packages/mui/src/FieldErrorTemplate/FieldErrorTemplate.tsx @@ -19,11 +19,13 @@ export default function FieldErrorTemplate< const id = errorId(idSchema); return ( - + {errors.map((error, i: number) => { return ( - {error} + + {error} + ); })} diff --git a/packages/mui/src/FieldHelpTemplate/FieldHelpTemplate.tsx b/packages/mui/src/FieldHelpTemplate/FieldHelpTemplate.tsx index 16424b7b3c..94ba216136 100644 --- a/packages/mui/src/FieldHelpTemplate/FieldHelpTemplate.tsx +++ b/packages/mui/src/FieldHelpTemplate/FieldHelpTemplate.tsx @@ -15,5 +15,9 @@ export default function FieldHelpTemplate< return null; } const id = helpId(idSchema); - return {help}; + return ( + + {help} + + ); } diff --git a/packages/mui/test/__snapshots__/Array.test.tsx.snap b/packages/mui/test/__snapshots__/Array.test.tsx.snap index 267cd09a2e..5ea20e10e8 100644 --- a/packages/mui/test/__snapshots__/Array.test.tsx.snap +++ b/packages/mui/test/__snapshots__/Array.test.tsx.snap @@ -4205,17 +4205,18 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-16:focus::-ms-input-

diff --git a/packages/mui/test/__snapshots__/Form.test.tsx.snap b/packages/mui/test/__snapshots__/Form.test.tsx.snap index d9f3442807..6f30727c57 100644 --- a/packages/mui/test/__snapshots__/Form.test.tsx.snap +++ b/packages/mui/test/__snapshots__/Form.test.tsx.snap @@ -4738,25 +4738,26 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-12:focus::-ms-input- -

help me! -

+