Skip to content

Card button aria-label and title not correctly localized #17069

Closed

Description

@cbratschi

Describe the Bug

I am seeing [object Object] values for localized collection names in card buttons:

<a type="button" aria-label="[object Object] neu erstellen" class="btn btn--icon btn--icon-style-with-border btn--icon-only btn--size-medium btn--icon-position-right btn--withoutPopup btn--style-icon-label btn--round btn--withoutPopup" title="[object Object] neu erstellen" href="/admin/collections/pages/create"><span class="btn__content"><span class="btn__icon"><svg class="icon icon--plus" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><path class="stroke" d="M5.33333 9.99998H14.6667M9.99999 5.33331V14.6666" stroke-linecap="square"></path></svg></span></span></a>

Payload uses:

"aria-label": t('general:createNewLabel', {
  label
})

For localized collection labels, label is an object like { en: 'Pages', de: 'Seiten' }. German translation is {{label}} neu erstellen, so interpolating the object becomes [object Object] neu erstellen. Payload’s Button also copies aria-label into title, so both attributes show it.

Correct fix would be:

title = getTranslation(label, i18n)

...

"aria-label": t('general:createNewLabel', {
  label: title
})

Link to the code that reproduces this issue

https://github.com/cbratschi/payload

Reproduction Steps

Check the aria-label text in the admin panel for localized collection labels.

Which area(s) are affected?

area: core

Environment Info

Binaries:
  Node: 26.3.0
  npm: 11.16.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.5.0: Mon Apr 27 20:39:42 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T6031
  Available memory (MB): 65536
  Available CPU cores: 16

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Jun 19, 2026
  2. added
    area: core
    and removed
    validate-reproduction
    on Jun 19, 2026
  3. changed the title [-]Card button aria-label and not correctly localized[/-] [+]Card button aria-label and title not correctly localized[/+] on Jun 19, 2026
  4. stefantschierschke commented on Jul 2, 2026

    @stefantschierschke

    Confirmed on both 3.85.1 AND 3.85.2 - bug is still present.

    The line moved slightly since your linked commit; in v3.85.2 the offending
    call is at
    https://github.com/payloadcms/payload/blob/v3.85.2/packages/ui/src/widgets/CollectionCards/index.tsx#L109-L111
    (dist-shipped as line 111 of the compiled index.js).

    Rendered attributes (DE portal, labels: { plural: { de: 'Seiten', en: 'Pages' } }):

    aria-label="[object Object] neu erstellen"
    title="[object Object] neu erstellen"
    

    Both attributes carry the same broken string . the title propagates because
    Payload's Button sets title = aria-label unconditionally (see
    packages/ui/src/elements/Button/index.tsx, compiled dist/.../index.js line
    around 100).

    Your suggested fix (label: title, reusing the already-computed value from
    getTranslation(label, i18n) two lines above) is the cleanest. Happy to
    open a PR against main if that unblocks things.

    Image
  5. 1yakub commented on Aug 5, 2026

    @1yakub

    I can take this one if it's still open. The label just needs to go through getTranslation before it hits createNewLabel, same as the showAllLabel call right above it.

  6. stefantschierschke commented on Aug 25, 2026

    @stefantschierschke

    Still reproducible on 3.88.0 — unchanged since my report on 3.85.2 (three
    minor releases ago).

    packages/ui/src/widgets/CollectionCards/index.tsx#L109-L110 (v3.88.0):

    aria-label={t('general:createNewLabel', { label })}
    

    The raw label object is still interpolated, so screen readers announce
    "[object Object] neu erstellen". The same file already does it correctly
    two branches above (L52: t('general:showAllLabel', { label: title })
    with title = getTranslation(label, i18n)) and again at L124 — so this is
    a one-line change to match the surrounding code.

    There are now three open PRs for it (#17070, #17096, #17664), none merged,
    and the issue is still labelled needs-triage after two months. Could a
    maintainer triage it and pick whichever PR fits? Happy to help review or
    rebase if that unblocks things.

  7. emmpauldev commented on Aug 25, 2026

    @emmpauldev

    Same pattern exists in DocumentDrawerToggler:

    https://github.com/payloadcms/payload/blob/main/packages/ui/src/elements/DocumentDrawer/index.tsx#L48-L50

    aria-label={t(operation === 'create' ? 'fields:addNewLabel' : 'general:editLabel', {
      label: collectionConfig?.labels.singular,
    })}

    labels.singular is interpolated raw, so a localized label object (e.g. { en: 'Form', fr: 'Formulaire' }) renders the accessible name as "Add new [object Object]" on the "Add new" button of every relationship field whose related collection has localized labels. Both branches of the ternary are affected (addNewLabel and editLabel).

    Note the visible text of the same button is fine: AddNewRelation runs the label through getTranslation before interpolating. Only the aria-label breaks, and it takes precedence over the visible text for the accessible name, so screen readers get the broken one (WCAG 4.1.2).

    Reproduced on 3.86.0 and 3.88.0; the code is unchanged on current main. The getTranslation wrap proposed above would fix this occurrence too.

  8. removed
    status: needs-triage
    on Oct 26, 2026
  9. added
    area: core
    and removed
    area: core
    on Oct 27, 2026
  10. GermanJablo commented on Oct 29, 2026

    @GermanJablo
    Contributor

    Fixed in both release lines. The dashboard collection card button: #18358 (main) and #19116 (3.x). The document drawer toggler reported in the comments: #17959 (main) and #19154 (3.x). The 3.x fixes ship in the next 3.x release, and the main fix in the next v4 beta. Thanks for the report! The remaining sort buttons case is tracked in #19198.

  11. github-actions commented on Nov 4, 2026

    @github-actions
    Contributor

    🚀 This is included in version v3.93.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugPayload OSSarea: corev3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions