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: Cast the value as an Array in CheckboxesWidget #3379

Merged

Conversation

heath-freenome
Copy link
Member

@heath-freenome heath-freenome commented Jan 15, 2023

Reasons for making this change

Fixes #2141 by reimplementing #2142 for all themes but antd

When the value passed to the CheckboxesWidget was a single value rather than an array, things would break in the control

  • Updated the CheckboxesWidget in all themes but antd (which uses simpler logic) to fix ensure the value used in the helper functions is an array
  • Added a test in ArrayField_test.ts that verifies the fix
  • Updated the snapshot in bootstrap-4 which showed an issue when the value string contained an element of the enumeration value rather than the whole value
  • Refactored the common selectValue and deselectValue functions used in CheckboxesWidget into @rjsf/utils and used them in the CheckboxesWidget
  • Updated the CHANGELOG.md accordingly

Checklist

  • I'm updating documentation
  • 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 updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

Fixes rjsf-team#2141 by reimplementing rjsf-team#2142

When the value passed to the `CheckboxesWidget` was a single value rather than an array, things would break in the control
- Updated the `CheckboxesWidget` in all themes but `antd` (which uses simpler logic) to fix ensure the value used in the helper functions is an array
- Added a test in `ArrayField_test.ts` that verifies the fix
- Updated the snapshot in `bootstrap-4` which showed an issue when the value string contained an element of the enumeration value rather than the whole value
- Refactored the common `selectValue` and `deselectValue` functions used in `CheckboxesWidget` into `@rjsf/utils`
- Updated the `CHANGELOG.md` accordingly
…onsDeselectValue()` and `enumOptionsSelectValue()` from all the `CheckboxesWidget` implementations into `@rjsf/utils`
@heath-freenome heath-freenome merged commit 3887d1d into rjsf-team:main Jan 16, 2023
@heath-freenome heath-freenome deleted the reimplement-2142-fixing-2141 branch January 16, 2023 01:24
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this pull request Jun 8, 2023
* fix: Cast the value as an Array in CheckboxesWidget
Fixes rjsf-team#2141 by reimplementing rjsf-team#2142

When the value passed to the `CheckboxesWidget` was a single value rather than an array, things would break in the control
- Updated the `CheckboxesWidget` in all themes but `antd` (which uses simpler logic) to fix ensure the value used in the helper functions is an array
- Added a test in `ArrayField_test.ts` that verifies the fix
- Updated the snapshot in `bootstrap-4` which showed an issue when the value string contained an element of the enumeration value rather than the whole value
- Refactored the common `selectValue` and `deselectValue` functions used in `CheckboxesWidget` into `@rjsf/utils`
- Updated the `CHANGELOG.md` accordingly

* - Responded to reviewer feedback, including refactoring the `enumOptionsDeselectValue()` and `enumOptionsSelectValue()` from all the `CheckboxesWidget` implementations into `@rjsf/utils`
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this pull request Jun 8, 2023
* fix: Cast the value as an Array in CheckboxesWidget
Fixes rjsf-team#2141 by reimplementing rjsf-team#2142

When the value passed to the `CheckboxesWidget` was a single value rather than an array, things would break in the control
- Updated the `CheckboxesWidget` in all themes but `antd` (which uses simpler logic) to fix ensure the value used in the helper functions is an array
- Added a test in `ArrayField_test.ts` that verifies the fix
- Updated the snapshot in `bootstrap-4` which showed an issue when the value string contained an element of the enumeration value rather than the whole value
- Refactored the common `selectValue` and `deselectValue` functions used in `CheckboxesWidget` into `@rjsf/utils`
- Updated the `CHANGELOG.md` accordingly

* - Responded to reviewer feedback, including refactoring the `enumOptionsDeselectValue()` and `enumOptionsSelectValue()` from all the `CheckboxesWidget` implementations into `@rjsf/utils`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CheckboxesWidget should ensure that the value is an Array
2 participants