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
{{ message }}
Repository navigation
fix(ui): translate the collection label in the create new card button (3.x) - #19116
Port of #17664 to 3.x. The create button on the dashboard collection cards now passes the translated collection label to general:createNewLabel.
Why?
With localized collection labels (for example { en: 'Pages', de: 'Seiten' }), the raw label object was interpolated, so the button's aria-label and title read [object Object] neu erstellen. Reported in #17069 and confirmed on 3.85.1, 3.85.2 and 3.88.0.
… (3.x)
Collection cards passed the raw `label` to `general:createNewLabel`, so
localized collection labels rendered as "[object Object]" in the create
button's aria-label and title. Use the already translated `title`,
matching the `showAllLabel` call above it.
Port of #17664 to 3.x. `main` already includes this fix via #18358.
Co-authored-by: Yakub Hossain <[email protected]>
Reviewing files that changed from the base of the PR and between 9c39634 and bde895e.
Files selected for processing: 2
packages/ui/src/widgets/CollectionCards/index.tsx
test/i18n/e2e.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Walkthrough
The collection create-card aria-label now uses the translated collection title. An end-to-end test checks the Spanish aria-label and title.
Changes: Localized create-card label
Layer / File(s)
Summary
Translate the label and verify attributes packages/ui/src/widgets/CollectionCards/index.tsx, test/i18n/e2e.spec.ts
The create-card aria-label now interpolates the translated title. The end-to-end test checks that the Spanish aria-label and title equal Crear ES Collection 1s.
payloadcms/payload#17069: The change addresses the issue’s localized collection label in the card’s aria-label and title.
Suggested labels:v3
Merge Risk: Minimal · up to bde89
The localized create-card label is covered for both accessible attributes and presents no identified merge-blocking risk.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title names the main change: the collection label passed to the create new card button is now translated. It is specific and matches the diff, which changes the aria label to use the translated ti…
Description check
The description states the purpose of the change. It says the create button now passes the translated collection label to general:createNewLabel, which explains the raw label object was interpolated a…
Linked Issues check
Issue #17069 requires localized collection labels in the create-card link aria-label and title. packages/ui/src/widgets/CollectionCards/index.tsx now passes the translated title to `general:cr…
Out of Scope Changes check
The changes stay within issue #17069. The import reordering is formatting-only, and the added end-to-end test directly verifies the required localized attributes.
Full details: Title check
Explanation
The title names the main change: the collection label passed to the create new card button is now translated. It is specific and matches the diff, which changes the aria label to use the translated title in CollectionCards/index.tsx. The '(3.x)' suffix marks the backport target.
Full details: Description check
Explanation
The description states the purpose of the change. It says the create button now passes the translated collection label to general:createNewLabel, which explains the raw label object was interpolated and produced [object Object]. It also describes the e2e assertion added in test/i18n and the import sorting, both of which appear in the changeset.
Full details: Linked Issues check
Explanation
Issue #17069 requires localized collection labels in the create-card link aria-label and title. packages/ui/src/widgets/CollectionCards/index.tsx now passes the translated title to general:createNewLabel instead of the raw label. The new i18n end-to-end test checks Spanish aria-label and title values.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
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
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/widgets/CollectionCards/index.tsx
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
test/i18n/e2e.spec.ts
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
Comment @coderabbitai help to get the list of available commands.
### What?
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.
### How?
- Resolve `collectionConfig.labels.singular` with `getTranslation`
before calling `t`, matching #17959.
- Give the `relation-one` fixture localized labels and add an e2e test
that the relationship add-new button exposes `Add new Relation One`.
Co-authored-by: German Jablonski <[email protected]>
Co-authored-by: Christoph Bratschi <[email protected]>
…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]>
@GermanJablo thanks again for porting this. A small thing I noticed: the v3.93.0 release notes don't list me as a contributor. The releaser finds co-authors with a GitHub user search on the Co-authored-by email (generateReleaseNotes.ts, same code on main), and that search never matches users.noreply.github.com addresses. It returns 0 users for both co-author lines on this commit. A fix could read the login from the noreply address before searching. Want me to open a PR with a test? And if it's easy, could I be added to the v3.93.0 notes?
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 #17664 to
3.x. The create button on the dashboard collection cards now passes the translated collection label togeneral:createNewLabel.Why?
With localized collection labels (for example
{ en: 'Pages', de: 'Seiten' }), the raw label object was interpolated, so the button'saria-labelandtitleread[object Object] neu erstellen. Reported in #17069 and confirmed on 3.85.1, 3.85.2 and 3.88.0.mainalready includes this fix via #18358.How?
titlein the create button'saria-label, matching theshowAllLabelcall above it.test/i18ne2e assertion from fix(ui): translate the collection label in the create new card button #17664 for botharia-labelandtitle. It fails without the fix (Received: "Crear [object Object]") and passes with it.test/i18n/e2e.spec.ts.Thanks to @1yakub for the original fix and test, and to @cbratschi for the report and review.
Fixes #17069