From da6f8c41b0895da2813cbe2a57d81fe7ddbb3ceb Mon Sep 17 00:00:00 2001 From: thribhuvan003 Date: Thu, 9 Jul 2026 07:21:36 +0530 Subject: [PATCH 1/3] Fix 4448: preserve empty string titles in oneOf/anyOf options list --- packages/utils/src/optionsList.ts | 5 ++-- packages/utils/test/optionsList.test.ts | 38 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/optionsList.ts b/packages/utils/src/optionsList.ts index e5058f1a5b..a302c93827 100644 --- a/packages/utils/src/optionsList.ts +++ b/packages/utils/src/optionsList.ts @@ -87,10 +87,11 @@ export default function optionsList { })), ); }); + it('should keep an empty string title for a oneOf option instead of falling back to the value', () => { + const oneOfSchema: RJSFSchema = { + type: 'string', + oneOf: [ + { + const: 'empty', + title: '', + }, + { + const: 'active', + }, + ], + }; + expect(optionsList(oneOfSchema)).toEqual([ + { schema: oneOfSchema.oneOf![0], label: '', value: 'empty' }, + { schema: oneOfSchema.oneOf![1], label: 'active', value: 'active' }, + ]); + }); + it('should keep an empty string title for a discriminator option instead of falling back to the value', () => { + const anyOfSchema: RJSFSchema = { + discriminator: { + propertyName: 'animal', + }, + anyOf: [ + { + type: 'object', + title: '', + properties: { + animal: { + type: 'string', + const: 'dog', + }, + }, + }, + ], + }; + expect(optionsList(anyOfSchema)).toEqual([{ schema: anyOfSchema.anyOf![0], label: '', value: 'dog' }]); + }); it('should generate options for an anyOf object schema with a discriminator, titles in object', () => { const anyOfSchema: RJSFSchema = { title: 'string', From 6fe7bfdbe0ebfbe8110b977144687468932f156d Mon Sep 17 00:00:00 2001 From: thribhuvan003 Date: Thu, 9 Jul 2026 07:30:15 +0530 Subject: [PATCH 2/3] Add CHANGELOG entry for #5150 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56825e13e4..d9990540d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ should change the heading of the (upcoming) version to include a major version b ## @rjsf/utils +- Fixed `optionsList()` to preserve an explicitly empty string `title` on `oneOf`/`anyOf` options instead of falling back to the option's value, fixing [#4448](https://github.com/rjsf-team/react-jsonschema-form/issues/4448) - Updated `types.ts` to add `CyclicSchemaExpandProps` type and `CyclicSchemaExpandTemplate` in the `TemplatesType` - Updated `resolveAllReferences()` to add a new `markCycleOnDetection` prop which adds `RJSF_REF_CYCLE_KEY` marker (from `constants.ts`) to a schema that has been detected to have a cycle, partially fixing [#3907](https://github.com/rjsf-team/react-jsonschema-form/issues/3907) - Updated `hashForSchema()` to filter keys to remove `RJSF_REF_KEY` prefixed keys before hashing the schema From b24da807c2caea0016a7e1b8bfc18f7329a5d87b Mon Sep 17 00:00:00 2001 From: thribhuvan003 Date: Thu, 9 Jul 2026 20:40:41 +0530 Subject: [PATCH 3/3] Move CHANGELOG entry to end of utils fixes list --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9990540d8..68edba17d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,7 +75,6 @@ should change the heading of the (upcoming) version to include a major version b ## @rjsf/utils -- Fixed `optionsList()` to preserve an explicitly empty string `title` on `oneOf`/`anyOf` options instead of falling back to the option's value, fixing [#4448](https://github.com/rjsf-team/react-jsonschema-form/issues/4448) - Updated `types.ts` to add `CyclicSchemaExpandProps` type and `CyclicSchemaExpandTemplate` in the `TemplatesType` - Updated `resolveAllReferences()` to add a new `markCycleOnDetection` prop which adds `RJSF_REF_CYCLE_KEY` marker (from `constants.ts`) to a schema that has been detected to have a cycle, partially fixing [#3907](https://github.com/rjsf-team/react-jsonschema-form/issues/3907) - Updated `hashForSchema()` to filter keys to remove `RJSF_REF_KEY` prefixed keys before hashing the schema @@ -86,6 +85,7 @@ should change the heading of the (upcoming) version to include a major version b - Updated `Experimental_DefaultFormStateBehavior` to add a new `nestedDefaultsPrecedence` option - Updated `getDefaultFormState()` to use the new `nestedDefaultsPrecedence` option to control how defaults defined on multiple levels are merged together, fixing [#5089](https://github.com/rjsf-team/react-jsonschema-form/issues/5089) - Updated `omitExtraData()` to better handle `allOf`s containing multiple `if/then/else` blocks, matching fix in `SJSF`, fixing [#5142](https://github.com/rjsf-team/react-jsonschema-form/issues/5142) +- Fixed `optionsList()` to preserve an explicitly empty string `title` on `oneOf`/`anyOf` options instead of falling back to the option's value, fixing [#4448](https://github.com/rjsf-team/react-jsonschema-form/issues/4448) ## @rjsf/validator-ajv8