Skip to content

Commit 4b3bca1

Browse files
committed
Updated antd HelpField to consistently use Markdown for help text & restored text-danger logic in Bootstrap FieldHelpTemplate & updated core test to expect div.help-block instead of p.help-block
1 parent 6251cd5 commit 4b3bca1

File tree

14 files changed

+563
-7279
lines changed

14 files changed

+563
-7279
lines changed

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ should change the heading of the (upcoming) version to include a major version b
8787
- Fixed duplicate label and description rendering in `CheckboxWidget` by conditionally rendering them based on widget type
8888
- Updated `CheckboxWidget` to handle label and description rendering consistently
8989
- Modified `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
90-
- Updated `CheckboxWidget` to handle label and description rendering consistently
91-
- Modified `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
9290
- Updated `ObjectField` to change the removal of an additional property to defer the work to the `processPendingChange()` handler in `Form`, fixing [#4850](https://github.com/rjsf-team/react-jsonschema-form/issues/4850)
9391
- Updated `FallbackField` to support `object` and `array` types, and improved `ArrayField` so that it handles missing items properly with the fallback field
9492

@@ -105,7 +103,6 @@ should change the heading of the (upcoming) version to include a major version b
105103
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
106104
- Updated `ArrayFieldItemTemplate` to switch `size` from 'auto' to responsive values on the `Grid`, fixing [#4838](https://github.com/rjsf-team/react-jsonschema-form/issues/4838)
107105

108-
109106
## @rjsf/primereact
110107

111108
- Updated `FieldTemplate` to skip label and description rendering for checkbox widgets, fixing ([#4742](https://github.com/rjsf-team/react-jsonschema-form/issues/4742))
@@ -126,7 +123,6 @@ should change the heading of the (upcoming) version to include a major version b
126123
## @rjsf/utils
127124

128125
- Updated `getDefaultFormState()` to not save an undefined field value into an object when the type is `null` and `excludeObjectChildren` is provided, fixing [#4821](https://github.com/rjsf-team/react-jsonschema-form/issues/4821)
129-
- Added new `ADDITIONAL_PROPERTY_KEY_REMOVE` constant
130126

131127
## Dev / docs / playground
132128

packages/antd/src/templates/FieldTemplate/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default function FieldTemplate<
3131
displayLabel,
3232
errors,
3333
help,
34+
rawHelp,
3435
hidden,
3536
id,
3637
label,
@@ -99,7 +100,7 @@ export default function FieldTemplate<
99100
<Form.Item
100101
colon={colon}
101102
hasFeedback={schema.type !== 'array' && schema.type !== 'object'}
102-
help={help || (rawErrors?.length ? errors : undefined)}
103+
help={(!!rawHelp && help) || (rawErrors?.length ? errors : undefined)}
103104
htmlFor={id}
104105
label={displayLabel && !isCheckbox && label}
105106
labelCol={labelCol}
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, getUiOptions } from '@rjsf/utils';
1+
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
22
import Markdown from 'markdown-to-jsx';
33

44
/** The `FieldHelpTemplate` component renders any help desired for a field
@@ -10,29 +10,14 @@ export default function FieldHelpTemplate<
1010
S extends StrictRJSFSchema = RJSFSchema,
1111
F extends FormContextType = any,
1212
>(props: FieldHelpProps<T, S, F>) {
13-
const { fieldPathId, help, uiSchema = {}, registry } = props;
13+
const { fieldPathId, help } = props;
1414
if (!help) {
1515
return null;
1616
}
1717
const id = helpId(fieldPathId);
18-
const uiOptions = getUiOptions<T, S, F>(uiSchema, registry?.globalUiOptions);
19-
if (typeof help === 'string' && uiOptions.enableMarkdownInHelp) {
20-
return (
21-
<div id={id} className='help-block'>
22-
<Markdown options={{ disableParsingRawHTML: true }}>{help}</Markdown>
23-
</div>
24-
);
25-
}
26-
if (typeof help === 'string') {
27-
return (
28-
<p id={id} className='help-block'>
29-
{help}
30-
</p>
31-
);
32-
}
3318
return (
3419
<div id={id} className='help-block'>
35-
{help}
20+
<Markdown options={{ disableParsingRawHTML: true }}>{help as string}</Markdown>
3621
</div>
3722
);
3823
}

0 commit comments

Comments
 (0)