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

Infer type from enum if a type is not provided to SelectWidget #1100

Merged
merged 1 commit into from
Dec 13, 2018
Merged

Infer type from enum if a type is not provided to SelectWidget #1100

merged 1 commit into from
Dec 13, 2018

Conversation

LucianBuzzo
Copy link
Collaborator

@LucianBuzzo LucianBuzzo commented Dec 6, 2018

Connects to #1098

Change-type: minor
Signed-off-by: Lucian lucian.buzzo@gmail.com

Reasons for making this change

If a type is not provided in a schema containing an enum and the enum contains values that are not a string, then the form will incorrectly display errors, due to the value of a select always being a string.
This change makes a best effort to infer the type from the enum field if the type field is not present.

Checklist

  • I'm updating documentation
    • I've checked the rendering of the Markdown text I've added
    • If I'm adding a new section, I've updated the Table of Content
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
    • I've run npm run cs-format on my branch to conform my code to prettier coding style
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@LucianBuzzo
Copy link
Collaborator Author

@edi9999 Could you take a look at this PR please?

src/utils.js Outdated Show resolved Hide resolved
test/BooleanField_test.js Outdated Show resolved Hide resolved
Connects to #1098

Change-type: minor
Signed-off-by: Lucian <lucian.buzzo@gmail.com>
@edi9999
Copy link
Collaborator

edi9999 commented Dec 13, 2018

Looks good to me ! Merging !

@edi9999 edi9999 merged commit 0ac0da7 into rjsf-team:master Dec 13, 2018
pieplu pushed a commit to pieplu/react-jsonschema-form that referenced this pull request Dec 14, 2018
…team#1100)

Connects to rjsf-team#1098

Change-type: minor
Signed-off-by: Lucian <lucian.buzzo@gmail.com>
pieplu added a commit to pieplu/react-jsonschema-form that referenced this pull request Dec 14, 2018
Infer type from enum if a type is not provided to SelectWidget (rjsf-team#1100)
epicfaace pushed a commit that referenced this pull request Mar 5, 2019
* Infer type from enum if a type is not provided to SelectWidget (#1100)

Connects to #1098

Change-type: minor
Signed-off-by: Lucian <lucian.buzzo@gmail.com>

* No more useless div on schema field not additional

* Fix tests (remove useles html)
- Revert some test added by
https://github.com/mozilla-services/react-jsonschema-form/pull/1123/files
- use new css class for form-additional insted layout css class
for test selection

* Don't use WrapIfAdditonal Component to hav a clerer diff, but adding code duplicate

* Use a WrapIfAdditional Component to have a cleanner code / diff

* Fix tests

* Ignore vscode Ide folder

* Remove useless parentProps

* Fix old test selector for form additional
CodeGains pushed a commit to CodeGains/react-jsonschema-form that referenced this pull request Mar 5, 2019
…team#1158)

* Infer type from enum if a type is not provided to SelectWidget (rjsf-team#1100)

Connects to rjsf-team#1098

Change-type: minor
Signed-off-by: Lucian <lucian.buzzo@gmail.com>

* No more useless div on schema field not additional

* Fix tests (remove useles html)
- Revert some test added by
https://github.com/mozilla-services/react-jsonschema-form/pull/1123/files
- use new css class for form-additional insted layout css class
for test selection

* Don't use WrapIfAdditonal Component to hav a clerer diff, but adding code duplicate

* Use a WrapIfAdditional Component to have a cleanner code / diff

* Fix tests

* Ignore vscode Ide folder

* Remove useless parentProps

* Fix old test selector for form additional
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.

None yet

2 participants