You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Port of #17959 to 3.x. DocumentDrawerToggler now passes the translated collection label to fields:addNewLabel and general:editLabel.
Why?
With localized collection labels (for example { en: 'Pages', de: 'Seiten' }), the raw label object was interpolated, so the toggler's aria-label read Add new [object Object]. The accessible name overrides the correctly translated visible text for screen reader users. Reported in #17069, alongside the collection card occurrence fixed in #19116.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Walkthrough
The document drawer now resolves the collection’s singular label before using it in the translated trigger’s accessible name. An end-to-end test checks the label for a relationship field.
Changes: Localized document drawer label
Layer / File(s)
Summary
Resolve and verify the collection label packages/ui/src/elements/DocumentDrawer/index.tsx, test/fields-relationship/collections/Relation1/index.ts, test/fields-relationship/e2e.spec.ts
DocumentDrawerToggler resolves the collection’s singular label with getTranslation before using it in the translated aria-label. The relationship-field test collection defines English singular and plural labels, and the end-to-end test checks for Add new Relation One.
payloadcms/payload#17069: The issue reports localized collection labels rendered as [object Object] in button accessible names and titles. This change resolves the label before interpolation in the document drawer trigger.
Possibly related PRs
payloadcms/payload#17959: This PR applies the same localized-label resolution to the document drawer trigger and adds the same relationship-field regression test.
payloadcms/payload#19116: This PR resolves localized collection labels for create-button accessible names in CollectionCards.
Suggested labels:v3
Suggested reviewers:jarrodmflesch
Merge Risk: Minimal · up to 9621e
The localized drawer label fix is covered by an effective end-to-end test, with no remaining merge-blocking risk identified.
Pre-merge checks: 5
Check name
Status
Explanation
Description check
The description clearly explains the document drawer translation fix, its cause, implementation, and related test coverage.
Title check
The title clearly and concisely identifies the UI fix for translated document drawer labels.
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files.
Finishing Touches: 💡 1
📝 Generate docstrings
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
🛠️ Fix failing CI checks: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
packages/ui/src/elements/DocumentDrawer/index.tsx
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
…9209)
### What?
Fixes every remaining place on 3.x where a config label (a locale record
or label function) or another value that is not a string or number is
interpolated into a string without being resolved first.
User-visible fixes:
- **Sort buttons** in list column headers had `aria-label="Sort by
[object Object] Ascending"` when the field label is a locale record.
This is the remaining case from
[#19198](#19198).
- **Query preset bar**: "New", "Edit" and "Delete" preset labels, plus
the delete confirmation, rendered `[object Object]` when
`queryPresets.labels` uses locale records.
- **Number `hasMany` min/max errors** interpolated the whole array. They
now name the offending number.
- **Config errors** (`DuplicateGlobal`, `InvalidFieldName`,
`InvalidFieldRelationship`, `MissingFieldInputOptions`,
`ReservedFieldName`) and the **cloud-storage / payload-cloud delete
error logs** fall back to the field name or slug when the label is not a
plain string.
- `LinkEditor` was passing `i18n` as interpolation variables to `t()`.
### Why?
The other two sites from #19198 were fixed in
[#18358](#18358) and
[#19116](#19116) (dashboard
card) and [#19154](#19154)
(document drawer). This PR fixes the rest of the bug class at once
instead of one report at a time.
### How?
- I temporarily tightened `TFunction` to only accept primitive
interpolation values and ran `tsc -b`, then ran a TypeScript
compiler-API audit for the cases the compiler can't see (`any` values
and labels in template literals).
- Each site now resolves the label with `getTranslation`, or falls back
to the name or slug where there is no `i18n` instance.
- The `TFunction` type is unchanged, because narrowing it would be a
breaking change. The `main` port is
[#19208](#19208).
Tests:
- Unit test for the `hasMany` number message.
- e2e tests in the `i18n` suite for the sort button labels and the query
preset bar. Both fail on current 3.x with `[object Object]`.
Fixes#19198
Co-authored-by: German Jablonski <[email protected]>
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
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.
What?
Port of #17959 to
3.x.DocumentDrawerTogglernow passes the translated collection label tofields:addNewLabelandgeneral:editLabel.Why?
With localized collection labels (for example
{ en: 'Pages', de: 'Seiten' }), the raw label object was interpolated, so the toggler'saria-labelreadAdd new [object Object]. The accessible name overrides the correctly translated visible text for screen reader users. Reported in #17069, alongside the collection card occurrence fixed in #19116.How?
collectionConfig.labels.singularwithgetTranslationbefore callingt, matching fix(ui): translate document drawer labels #17959.relation-onefixture localized labels and add an e2e test that the relationship add-new button exposesAdd new Relation One.