-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
CheckboxesWidget should ensure that the value is an Array #2141
Comments
heath-freenome
added a commit
to heath-freenome/react-jsonschema-form
that referenced
this issue
Jan 15, 2023
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 - Updated the `CHANGELOG.md` accordingly
8 tasks
heath-freenome
added a commit
to heath-freenome/react-jsonschema-form
that referenced
this issue
Jan 15, 2023
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 - Updated the `CHANGELOG.md` accordingly
heath-freenome
added a commit
to heath-freenome/react-jsonschema-form
that referenced
this issue
Jan 16, 2023
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
heath-freenome
added a commit
that referenced
this issue
Jan 16, 2023
* fix: Cast the value as an Array in CheckboxesWidget Fixes #2141 by reimplementing #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 issue
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 issue
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
Prerequisites
Description
CheckboxesWidget
assumes that thevalue
is an Array but does not check the type of the value.At runtime, the widget will throw an exception when a value is selected or deselected.
Steps to Reproduce
See the codesandbox example: https://codesandbox.io/s/checkboxeswidget-with-non-array-value-react-jsonschema-form-qi96b?file=/src/App.js
Important parts:
Expected behavior
The widget should check that the value is an Array. If not, the widget could either create an Array from the value or ignore the value.
Actual behavior
Throws an exception when the user is trying to select or deselect a value.
Please note that the value passed as a String will be correctly selected.
In the above example, the value "Essai" is selected (even if the value was
Essai
and not["Essai"]
):Version
2.4.0
The text was updated successfully, but these errors were encountered: