Skip to content

Fix 4448: preserve empty string titles in oneOf/anyOf options list#5150

Open
thribhuvan003 wants to merge 2 commits into
rjsf-team:mainfrom
thribhuvan003:fix/4448-empty-string-option-title
Open

Fix 4448: preserve empty string titles in oneOf/anyOf options list#5150
thribhuvan003 wants to merge 2 commits into
rjsf-team:mainfrom
thribhuvan003:fix/4448-empty-string-option-title

Conversation

@thribhuvan003

Copy link
Copy Markdown

Reasons for making this change

optionsList() builds oneOf/anyOf option labels with || chains, so an explicitly empty string title ({ const: 'empty', title: '' }) is treated as missing and the label falls back to the const value. switched the fallbacks to ?? so an empty title is kept while undefined still falls through to the schema title / value as before. added tests for the plain oneOf case and the discriminator path.

fixes #4448

Checklist

  • I'm updating documentation — n/a, behavior matches the documented title precedence
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated the CHANGELOG.md (in the follow-up commit with this PR's number)

Comment thread CHANGELOG.md

## @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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this at the end of the list of fixes?

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.

oneOf + const enums do not use empty string title

2 participants