Repository navigation
fix(daisyui): translate the SelectWidget empty-selection fallback - #5512
heath-freenome merged 7 commits into
Conversation
Size limit reportSizes are minified + brotli, measured by size-limit at A package listed twice is measured both as installed and, on the second row, as its own code with its dependencies excluded. Peer dependencies are always excluded.
|
|
|
||
| ## @rjsf/daisyui | ||
|
|
||
| - Fixed the `SelectWidget` trigger falling back to a hardcoded `'Select...'` with no value selected, no `ui:placeholder` and no label, fixing [#5498](https://github.com/rjsf-team/react-jsonschema-form/issues/5498). The fallback now reads `translateString(TranslatableString.SelectPlaceholder)`, the way the shadcn widget does, so a custom `translateString` localizes it (the default English text becomes `'Select ...'`) |
There was a problem hiding this comment.
This entry is in the wrong changelog. The PR targets v7, whose entries go in CHANGELOG-v7.md under # 7.0.0 → ## @rjsf/daisyui; this line lands in CHANGELOG.md under # 6.9.0, which is already tagged and released (v6.9.0), so the release notes would attribute the fix to a version that doesn't contain it. TranslatableString.SelectPlaceholder itself only exists on v7 (it is listed under @rjsf/utils in CHANGELOG-v7.md), so the entry can't be true of any 6.x release.
Could you move it to CHANGELOG-v7.md, as the last bullet of the ## @rjsf/daisyui section rather than the first?
There was a problem hiding this comment.
Right, moved in c8b12db: the entry is out of CHANGELOG.md (6.9.0 is tagged) and now the last bullet of the ## @rjsf/daisyui section in CHANGELOG-v7.md.
| {hasValue ? selectedLabels.join(', ') : placeholder || label || 'Select...'} | ||
| {hasValue | ||
| ? selectedLabels.join(', ') | ||
| : placeholder || label || registry.translateString(TranslatableString.SelectPlaceholder)} |
There was a problem hiding this comment.
Two consumer-visible effects of this line that the v7 upgrade guide doesn't cover for daisyui yet:
- The default English text changes from
Select...toSelect .... Where no label names the button (a root field, aoneOf/anyOfoption selector) that text is also its accessible name, so a consumer'sgetByRole('button', { name: 'Select...' })or snapshot of a daisyui form breaks. - A
translateStringbuilt as a lookup table without a fallback toenglishStringTranslatorreturnsundefinedfor the new key. The trigger then renders empty, and in the unlabeled case the button is left with no accessible name at all (the▼isaria-hidden), where it used to saySelect....
The guide's section "@rjsf/shadcn's SelectWidget names its combobox and fills empty placeholders" already tells shadcn users that a translateString table gains the TranslatableString.SelectPlaceholder key and that snapshots change; daisyui users need the same note (either there or in the daisyui markup section).
There was a problem hiding this comment.
Done in c8b12db: added a section to the v7 upgrade guide right after the shadcn one. It covers both effects - the Select... -> Select ... text change (and the snapshot/getByRole breakage where the text was the trigger's accessible name) and the SelectPlaceholder key that a lookup-table translateString needs, with the empty-trigger failure spelled out.
| WidgetProps, | ||
| } from '@rjsf/utils'; | ||
| import { | ||
| TranslatableString, |
There was a problem hiding this comment.
The JSDoc on this key in packages/utils/src/enums.ts still reads "used by the shadcn SelectWidget":
/** Placeholder for a select input, and its accessible name when the field has no title, used by the shadcn SelectWidget */
SelectPlaceholder: 'Select ...',With this change daisyui's SelectWidget reads it too, so the comment should name both (the neighbouring keys list their users the same way, e.g. "used by the daisyUI date pickers").
There was a problem hiding this comment.
Done in c8b12db - the JSDoc now names the shadcn and daisyui SelectWidgets.
jimmycallin
left a comment
There was a problem hiding this comment.
Thanks for the quick update, this looks good. Two small things before merging:
- Changelog: please move the new bullet to the end of the
## @rjsf/daisyuilist inCHANGELOG-v7.md. It is currently inserted before theTextareaWidgetbullet; new entries go after the existing ones. - Upgrade guide: please remove the section added to
v7.x upgrade guide.md. On reflection this isn't a breaking change, so it doesn't belong there, and the changelog entry already covers the new default text. Sorry for the back and forth on that one.
|
Done in a7c3b97: the changelog bullet is now the last one in the |
|
Please resolve conflicts |
The trigger fell back to a hardcoded 'Select...' with no value selected, no ui:placeholder and no label, so a translateString mapping TranslatableString.SelectPlaceholder localized the shadcn widget but not this one. Read the fallback through registry.translateString the way shadcn does. Fixes rjsf-team#5498. Signed-off-by: Charan Rathore <[email protected]>
Signed-off-by: Charan Rathore <[email protected]>
Signed-off-by: Charan Rathore <[email protected]>
…ing the readonly registry Signed-off-by: Charan Rathore <[email protected]>
The entry sat in CHANGELOG.md under 6.9.0, which is already tagged; it belongs to v7, whose TranslatableString.SelectPlaceholder key it describes. The upgrade guide notes the daisyui trigger text change and the new translateString key, and the key's JSDoc names both SelectWidget users. Signed-off-by: Charan Rathore <[email protected]>
…op the upgrade guide section The fix is not a breaking change, so the v7 upgrade guide does not carry it; the changelog entry covers the new default text. Signed-off-by: Charan Rathore <[email protected]>
Fixes #5498
What was wrong
With no value selected, no
ui:placeholderand no label, the daisyuiSelectWidgettrigger fell back to a hardcoded'Select...', so atranslateStringmappingTranslatableString.SelectPlaceholderlocalized the shadcn widget but not this one.The fix
The fallback now reads
registry.translateString(TranslatableString.SelectPlaceholder), the way the shadcn widget does. The default English text becomes'Select ...'(the enum's value), matching shadcn.Tests
SelectWidget.test.tsx: a customtranslateStringmaps the placeholder, and the trigger renders the translated fallback.FormandArraysnapshots updated for the default text change (Select...toSelect ...); the diff is text-only.SelectWidget.test.tsxpasses 21/21. Note: theadditionalPropertiescases inObject.test.tsxfail their snapshots on currentv7in my environment both with and without this change, so I left that snapshot file untouched.Checklist
CHANGELOG.mdfor the package(s) I modified