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

oneOf change of default behaviour #4377

Open
4 tasks done
jam13 opened this issue Nov 12, 2024 · 1 comment
Open
4 tasks done

oneOf change of default behaviour #4377

jam13 opened this issue Nov 12, 2024 · 1 comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned

Comments

@jam13
Copy link

jam13 commented Nov 12, 2024

Prerequisites

What theme are you using?

antd

Version

5.x

Current Behavior

oneOf used to behave like enum in that it defaulted to undefined unless a default had been specified. It is now defaulting to the first item in the oneOf list.

Expected Behavior

oneOf should behave the same as enum and default to undefined.

Steps To Reproduce

https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJvbmVPZk5vRGVmYXVsdCI6InllcyIsIm9uZU9mTnVsbERlZmF1bHQiOm51bGx9LCJzY2hlbWEiOnsidHlwZSI6Im9iamVjdCIsInByb3BlcnRpZXMiOnsiZW51bU5vRGVmYXVsdCI6eyJ0aXRsZSI6ImVudW1OYW1lcywgbm8gZGVmYXVsdCIsImVudW0iOlsieWVzIiwibm8iXX0sIm9uZU9mTm9EZWZhdWx0Ijp7InRpdGxlIjoib25lT2YsIG5vIGRlZmF1bHQiLCJ0eXBlIjoic3RyaW5nIiwib25lT2YiOlt7ImNvbnN0IjoieWVzIiwidGl0bGUiOiJZZXMifSx7ImNvbnN0Ijoibm8iLCJ0aXRsZSI6Ik5vIn1dfSwib25lT2ZOdWxsRGVmYXVsdCI6eyJ0eXBlIjoic3RyaW5nIiwidGl0bGUiOiJvbmVPZiwgbnVsbCBkZWZhdWx0IiwiZGVmYXVsdCI6bnVsbCwib25lT2YiOlt7ImNvbnN0IjoieWVzIiwidGl0bGUiOiJZZXMifSx7ImNvbnN0Ijoibm8iLCJ0aXRsZSI6Ik5vIn1dfX19LCJ1aVNjaGVtYSI6eyJlbnVtTm9EZWZhdWx0Ijp7InVpOndpZGdldCI6IlJhZGlvV2lkZ2V0IiwidWk6ZW51bU5hbWVzIjpbIlllcyIsIk5vIl19LCJvbmVPZk5vRGVmYXVsdCI6eyJ1aTp3aWRnZXQiOiJSYWRpb1dpZGdldCJ9LCJvbmVPZk51bGxEZWZhdWx0Ijp7InVpOndpZGdldCI6IlJhZGlvV2lkZ2V0In19LCJ0aGVtZSI6ImRlZmF1bHQiLCJsaXZlU2V0dGluZ3MiOnsic2hvd0Vycm9yTGlzdCI6InRvcCIsImV4cGVyaW1lbnRhbF9kZWZhdWx0Rm9ybVN0YXRlQmVoYXZpb3IiOnsiYXJyYXlNaW5JdGVtcyI6eyJwb3B1bGF0ZSI6InBvcHVsYXRlIiwibWVyZ2VFeHRyYURlZmF1bHRzIjpmYWxzZX0sImFsbE9mIjoic2tpcERlZmF1bHRzIiwiZW1wdHlPYmplY3RGaWVsZHMiOiJwb3B1bGF0ZUFsbERlZmF1bHRzIiwibWVyZ2VEZWZhdWx0c0ludG9Gb3JtRGF0YSI6InVzZUZvcm1EYXRhSWZQcmVzZW50In19fQ==

Environment

N/A

Anything else?

No response

@jam13 jam13 added bug needs triage Initial label given, to be assigned correct labels and assigned labels Nov 12, 2024
@MarekBodingerBA
Copy link
Contributor

Duplicate of #4361

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Nov 14, 2024
…ression

Fixes rjsf-team#4344, rjsf-team#4361 and rjsf-team#4377
- In `@rjsf/utils`:
  - Updated the `Experimental_DefaultFormStateBehavior` type to add new optional `constAsDefaults` prop with three choices
  - Updated `getDefaultFormState()` to respond to the new `constAsDefaults` feature to limit `const` as defaults based on the `never` or `skipOneOf` choices
  - Added tests for `getDefaultFormState()` to verify the new feature
- In `@rjsf/core`:
  - Updated `SchemaField` to remove making the field readonly when const
- In `playground`:
  - Updated `Header` to add support for `constAsDefaults`
- Updated the `CHANGELOG.md` accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned
Projects
None yet
Development

No branches or pull requests

2 participants