Feat/UI initial value and required#5001
Draft
adamrimon wants to merge 6 commits intorjsf-team:mainfrom
Draft
Conversation
2ef05b7 to
302da71
Compare
… widget clear Threaded uiSchema through the getDefaultFormState pipeline so that ui:emptyValue is used as a fallback whenever a field is blank, regardless of whether it became blank from initial state, reset, or user clearing.
ui:initialValue takes priority over schema.default and is used when the form is first rendered or after a reset. It does not override user-provided formData. emptyValue remains the fallback for blank fields.
302da71 to
6445eba
Compare
ui:required: true adds the field to validation and shows the required indicator. ui:required: false hides the indicator but schema validation still runs. Emits console.warn when ui:required: false is used on a schema-required field without ui:initialValue or ui:emptyValue.
6445eba to
d2bc4cf
Compare
Member
|
@adamrimon Wow, making changes for v7 already. We have a few others queuing up for it. I hope I have some time to prepare the long-lived branch for it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reasons for making this change
Fixes #4983
ui:emptyValueonly applies when the user actively clears a field. If the user never touches it, or the form is reset, there is no equivalent. This is a gap when the JSON schema is auto-generated and a separate uiSchema layer controls the UX.This PR:
ui:emptyValueto apply whenever a field is blank, regardless of the reason (initial render, reset, or user clearing), by threadinguiSchemathrough thegetDefaultFormStatepipelineui:initialValueto pre-fill a field on render/reset, taking priority overschema.default(useful for hidden fields that need a fixed value)ui:requiredto override the schema's required status for a field.trueadds the indicator and validation,falsehides the indicator but does not suppress schema validation. Emitsconsole.warnfor misleading configurationsThe
ui:emptyValueextension is a breaking change (previously only fired on explicit clear), hence the major version bump to 7.0.0.Checklist
npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:updateto update snapshots, if needed.