-
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
ui:emptyValue does not work with selects #1041
Comments
Same problem here...
|
I have similar issue with the enums. Here is the playground link Based on the documentation here - https://react-jsonschema-form.readthedocs.io/en/latest/validation/#the-case-of-empty-strings |
As far as I can see, the react-jsonschema-form/packages/core/src/components/widgets/SelectWidget.js Lines 15 to 16 in b78d9ef
Is that it? |
- This is a reimplementation of rjsf-team#2251 - Fixes rjsf-team#1041
* Use ui:emptyValue for SelectWidget - This is a reimplementation of rjsf-team#2251 - Fixes rjsf-team#1041 * - Added `processSelectValue()` to `fluent-ui` for single select * - Fixed documentation for `emptyValue` * - Responded to self-feedback
Fixed in v5 beta via #3026, see the 5.x migration guide |
Prerequisites
Description
ui:emptyValue
is ignored for select widgets, requiring messy workarounds to resolve due to the way that the empty value option is injected.The workaround that works is to specify a non-falsy empty value (e.g.
"0"
) as the default for the form input (required in order to prevent the empty<option>
from being injected), add your own empty value to the enum / enumNames (e.g."0"
as the value, "None" as the name), then reprocess to treat that empty value appropriately in the code dealing with the form (if"0"
is OK then that's fine, but if you want a falsy default, e.g. an empty string, more work is required).Obviously this is much more complex than just specifying
ui:emptyValue
with the desired value.Steps to Reproduce
ui:emptyValue
settingui:emptyValue
is not usedSimple playground reproduction
Expected behavior
The formData value should be the
ui:emptyValue
when the empty option is selected.Actual behavior
There is no formData value for the field when the empty option is selected.
Version
Current playground version.
The text was updated successfully, but these errors were encountered: