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

fix(antd): disabled property of options of antd theme #4216

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ should change the heading of the (upcoming) version to include a major version b

-->

# 5.18.6

## @rjsf/antd

- Fix disabled property of options in CheckboxesWidget and RadioWidget ([#4216](https://github.com/rjsf-team/react-jsonschema-form/pull/4216))

# 5.18.5

## @rjsf/antd
Expand Down
2 changes: 1 addition & 1 deletion PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If your PR is non-trivial and you'd like to schedule a synchronous review, pleas
- [ ] **I'm updating documentation**
- [ ] I've [checked the rendering](https://rjsf-team.github.io/react-jsonschema-form/docs/contributing) of the Markdown text I've added
- [ ] **I'm adding or updating code**
- [ ] I've added and/or updated tests. I've run `npm run test:update` to update snapshots, if needed.
- [ ] I've added and/or updated tests. I've run `npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update` to update snapshots, if needed.
- [ ] I've updated [docs](https://rjsf-team.github.io/react-jsonschema-form/docs) if needed
- [ ] I've updated the [changelog](https://github.com/rjsf-team/react-jsonschema-form/blob/main/CHANGELOG.md) with a description of the PR
- [ ] **I'm adding a new feature**
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/src/widgets/CheckboxesWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function CheckboxesWidget<
id={optionId(id, i)}
name={id}
autoFocus={i === 0 ? autofocus : false}
disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1}
disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1}
value={String(i)}
>
{option.label}
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/src/widgets/RadioWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
id={optionId(id, i)}
name={id}
autoFocus={i === 0 ? autofocus : false}
disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1}
disabled={Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1}
key={i}
value={String(i)}
>
Expand Down
285 changes: 285 additions & 0 deletions packages/antd/test/__snapshots__/Form.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2674,6 +2674,181 @@ exports[`single fields select field multiple choice enumDisabled 1`] = `
</form>
`;

exports[`single fields select field multiple choice enumDisabled using checkboxes 1`] = `
<form
className="rjsf"
noValidate={false}
onSubmit={[Function]}
>
<div
className="form-group field field-array"
>
<div
className="ant-form-item css-dev-only-do-not-override-1b0bdye"
>
<div
className="ant-row ant-form-item-row css-dev-only-do-not-override-1b0bdye"
style={
{
"rowGap": undefined,
}
}
>
<div
className="ant-col ant-col-24 ant-form-item-control css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<div
className="ant-form-item-control-input"
>
<div
className="ant-form-item-control-input-content"
>
<div
aria-describedby="root__error root__description root__help"
className="ant-checkbox-group css-dev-only-do-not-override-1b0bdye"
id="root"
name="root"
onBlur={[Function]}
onFocus={[Function]}
>
<span>
<label
className="ant-checkbox-wrapper ant-checkbox-wrapper-in-form-item css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<span
className="ant-checkbox ant-wave-target css-dev-only-do-not-override-1b0bdye"
>
<input
autoFocus={false}
checked={false}
className="ant-checkbox-input"
disabled={false}
id="root-0"
name="root"
onChange={[Function]}
type="checkbox"
value="0"
/>
<span
className="ant-checkbox-inner"
/>
</span>
<span>
foo
</span>
</label>
<br />
</span>
<span>
<label
className="ant-checkbox-wrapper ant-checkbox-wrapper-disabled ant-checkbox-wrapper-in-form-item css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<span
className="ant-checkbox ant-wave-target css-dev-only-do-not-override-1b0bdye ant-checkbox-disabled"
>
<input
autoFocus={false}
checked={false}
className="ant-checkbox-input"
disabled={true}
id="root-1"
name="root"
onChange={[Function]}
type="checkbox"
value="1"
/>
<span
className="ant-checkbox-inner"
/>
</span>
<span>
bar
</span>
</label>
<br />
</span>
<span>
<label
className="ant-checkbox-wrapper ant-checkbox-wrapper-in-form-item css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<span
className="ant-checkbox ant-wave-target css-dev-only-do-not-override-1b0bdye"
>
<input
autoFocus={false}
checked={false}
className="ant-checkbox-input"
disabled={false}
id="root-2"
name="root"
onChange={[Function]}
type="checkbox"
value="2"
/>
<span
className="ant-checkbox-inner"
/>
</span>
<span>
fuzz
</span>
</label>
<br />
</span>
<span>
<label
className="ant-checkbox-wrapper ant-checkbox-wrapper-in-form-item css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<span
className="ant-checkbox ant-wave-target css-dev-only-do-not-override-1b0bdye"
>
<input
autoFocus={false}
checked={false}
className="ant-checkbox-input"
disabled={false}
id="root-3"
name="root"
onChange={[Function]}
type="checkbox"
value="3"
/>
<span
className="ant-checkbox-inner"
/>
</span>
<span>
qux
</span>
</label>
<br />
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<button
className="ant-btn css-dev-only-do-not-override-1b0bdye ant-btn-submit"
disabled={false}
onClick={[Function]}
style={{}}
type="submit"
>
<span>
Submit
</span>
</button>
</form>
`;

exports[`single fields select field multiple choice formData 1`] = `
<form
className="rjsf"
Expand Down Expand Up @@ -3269,6 +3444,116 @@ exports[`single fields select field single choice enumDisabled 1`] = `
</form>
`;

exports[`single fields select field single choice enumDisabled using radio widget 1`] = `
<form
className="rjsf"
noValidate={false}
onSubmit={[Function]}
>
<div
className="form-group field field-string"
>
<div
className="ant-form-item css-dev-only-do-not-override-1b0bdye"
>
<div
className="ant-row ant-form-item-row css-dev-only-do-not-override-1b0bdye"
style={
{
"rowGap": undefined,
}
}
>
<div
className="ant-col ant-col-24 ant-form-item-control css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<div
className="ant-form-item-control-input"
>
<div
className="ant-form-item-control-input-content"
>
<div
aria-describedby="root__error root__description root__help"
className="ant-radio-group ant-radio-group-outline css-dev-only-do-not-override-1b0bdye"
id="root"
onBlur={[Function]}
onFocus={[Function]}
>
<label
className="ant-radio-wrapper ant-radio-wrapper-in-form-item css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<span
className="ant-radio ant-wave-target"
>
<input
autoFocus={false}
checked={false}
className="ant-radio-input"
disabled={false}
id="root-0"
name="root"
onChange={[Function]}
type="radio"
value="0"
/>
<span
className="ant-radio-inner"
/>
</span>
<span>
foo
</span>
</label>
<label
className="ant-radio-wrapper ant-radio-wrapper-disabled ant-radio-wrapper-in-form-item css-dev-only-do-not-override-1b0bdye"
style={{}}
>
<span
className="ant-radio ant-wave-target ant-radio-disabled"
>
<input
autoFocus={false}
checked={false}
className="ant-radio-input"
disabled={true}
id="root-1"
name="root"
onChange={[Function]}
type="radio"
value="1"
/>
<span
className="ant-radio-inner"
/>
</span>
<span>
bar
</span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<button
className="ant-btn css-dev-only-do-not-override-1b0bdye ant-btn-submit"
disabled={false}
onClick={[Function]}
style={{}}
type="submit"
>
<span>
Submit
</span>
</button>
</form>
`;

exports[`single fields select field single choice formData 1`] = `
<form
className="rjsf"
Expand Down
Loading