Repository navigation
fix(ui): translate document drawer labels - #17959
GermanJablo merged 3 commits into
Conversation
…idget The client widget passed the same raw label object to createNewLabel as the RSC widget did. Adds the i18n e2e assertion on the dashboard create button, and the localized label fixture plus the drawer toggler aria-label test from payloadcms#17959 so the two PRs can be consolidated here.
Kept split by component per review: the drawer toggler fix, the localized relationship fixture and the accessibility test live in payloadcms#17959.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Resolve and verify the singular label packages/ui/src/elements/DocumentDrawer/index.tsx, test/fields-relationship/collections/Relation1/index.ts, test/fields-relationship/e2e.spec.ts |
DocumentDrawerToggler resolves the singular collection label before using it in the translated aria label. The relationship fixture adds singular and plural labels, and the end-to-end test checks for “Add new Relation One.” |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Possibly related issues
payloadcms/payload#17069: Reports the same localized-label interpolation defect in another admin control. This change fixes theDocumentDrawerToggleroccurrence; theCollectionCardsoccurrence remains out of scope.
Possibly related PRs
- payloadcms/payload#19116: Fixes localized collection labels in
CollectionCardscreate-button labels and titles.
Merge Risk: 
Minimal · previous review 6ba30
-
The localized accessible-name change is supported by the source contracts and regression coverage, with no remaining merge-blocking risk.
Pre-merge checks: 
5
-
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 unit tests (beta)
-
- 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
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]>
…9208) ### What? Fixes every remaining place where a config label (a locale record or label function) or another non-primitive value is interpolated into a string without being resolved first. User-visible fixes: - **Group by button** showed `Group by [object Object]` for fields nested in a group or named tab, because `ReducedField.label` holds JSX there. It now uses `plainTextLabel`. `reduceFieldsToOptions` also falls back to the humanized field name for `label: false` fields, as `combineFieldLabel` already does, so the button no longer reads `Group by Meta > `. - **Number `hasMany` min/max errors** interpolated the whole array (`1,2,30 is greater than the max allowed value of 10`). They now name the offending number. - **Config errors** (`DuplicateGlobal`, `InvalidFieldName`, `InvalidFieldRelationship`, `MissingFieldInputOptions`, `ReservedFieldName`) and the **cloud-storage / payload-cloud delete error logs** printed `[object Object]` or the source of a label function. They now fall back to the field name or slug when the label is not a plain string, which matches the existing pattern in `saveVersion.ts`. - `LinkEditor` was passing `i18n` as interpolation variables to `t()`. ### Why? Follow-up to [#19198](#19198), [#17959](#17959) and [#18358](#18358). These bugs keep coming back one at a time because `TFunction` accepts `options?: Record<string, any>`, and the runtime stringifies each value, so objects become `[object Object]`. ### How? - I found the sites by temporarily narrowing `TFunction` to primitive values and running `tsc -b`, then running a TypeScript compiler-API audit for what the compiler can't see: `any` values, labels in template literals, and `aria-label`, `title`, `placeholder` and `alt` attributes across all packages. The remaining hits are counts, filenames, document titles and GraphQL type names. - The `TFunction` type is unchanged. Narrowing it would stop correct code from compiling (for example booleans or `Date` values, which the runtime stringifies fine), which is a breaking change under the [versioning policy](https://github.com/payloadcms/payload/blob/main/docs/migration-guide/versioning.mdx). Tests: - Unit test for the `hasMany` number message. - e2e tests for the Group by button with a nested field and with a nested `label: false` field. The first fails on `main` with `Group by [object Object]`. - e2e test for the sort button labels with a locale-record field label. 3.x port: [#19209](#19209) --------- Co-authored-by: German Jablonski <[email protected]>
|
🚀 This is included in version v4.0.0-beta.7 |
What?
Translate localized collection labels before interpolating them into
DocumentDrawerToggleraccessible names.Add an E2E regression using a localized singular label and verify that the relationship add-new button exposes
Add new Relation Oneinstead ofAdd new [object Object].Why?
DocumentDrawerTogglerpassescollectionConfig.labels.singulardirectly to i18next. When the label is a localized object, the generatedaria-labelcontains[object Object]. The accessible name then overrides the correctly translated visible button text for screen-reader users.This addresses the additional
DocumentDrawerToggleroccurrence reported in #17069. The originalCollectionCardsoccurrence remains separate.How?
Resolve the collection label with
getTranslationand the active i18n instance before callingt. The relationship fixture now uses a localized label so the Playwright assertion exercises the real configuration shape.Validation:
git diff --check