Skip to content

Media: Refresh attachment tile aria-label when model data loads - #13053

Closed
sornapudisuresh wants to merge 3 commits into
WordPress:trunkfrom
sornapudisuresh:fix/65852-media-attachment-aria-label
Closed

sornapudisuresh wants to merge 3 commits into
WordPress:trunkfrom
sornapudisuresh:fix/65852-media-attachment-aria-label

Conversation

@sornapudisuresh

Copy link
Copy Markdown

Media Library grid tiles can keep a stale aria-label (uploading… / (no title)) when the view is created for an id-only attachment model that is still fetching. The visible CSS label overlay (added in 7.0) makes that staleness obvious to everyone, not only screen reader users.

Problem

wp.media.view.Attachment computes aria-label only in attributes(), and Backbone evaluates that once during _ensureElement(). Core (and Gutenberg) often create tiles via Attachment.get( id ) + fetch(), so the label is computed from empty model data and never updates when the model later receives a title — even though render() re-runs on model change.

This is distinct from #65438 / [62892], which only changes which fallback string is used for a titleless model.

Fix

  • Factor the label computation into getAriaLabel().
  • Re-apply aria-label at the end of render() once the model has data.
  • Skip subclasses that reset attributes (e.g. Attachment.Details, see #47458) so we do not add inappropriate attributes there.
  • Leave aria-checked alone so selection state from updateSelect() is not clobbered.

Testing instructions

  1. Use the Playground blueprint from the Trac ticket, or locally:
    • Create a post with a titled featured image.
    • Reload the post edit screen and open the Featured image modal.
  2. Confirm the selected tile label updates to the attachment title (not stuck on uploading… / (no title)).
  3. Confirm untitled tiles still show (no title), and in-progress uploads still show uploading….
  4. Confirm Attachment Details (sidebar) is unchanged (no checkbox/aria-label attributes added).

Trac ticket: https://core.trac.wordpress.org/ticket/65852

Use of AI Tools

AI assistance: Yes
Tool(s): Cursor
Model(s): Cursor Grok 4.5
Used for: Implementation assistance following the approach suggested on the Trac ticket. Changes were reviewed against the codebase and existing Attachment.Details attribute reset pattern.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sureshsornapudi09, afercia.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@afercia

afercia commented Sep 14, 2026

Copy link
Copy Markdown
Member

I quickly tested the approach in this PR and wanted to note that it also fixes a small quirk when uploading multiple attachments at the same time in the Media Library, which makes sense given the label is now updated on render.

Before:

  • Go to the Media Library, grid mode.
  • Upload 10 attachments at the same time by dragging them into the Media Library.
  • Observe that while the attachments get uploaded, the label in the tile is uploading… for all of them.
  • Observe that only when all the 10 attachments are fully uploaded, their labels update to the actual title.

After:

  • Repeat the steps above.
  • Observe that each attachment label updates as soon as each individual attachment is fully uploaded.

sornapudisuresh and others added 3 commits October 10, 2026 14:38
Backbone only evaluates attributes() when the element is created, so tiles
built for id-only models kept a stale uploading/(no title) label after fetch.
Re-apply the accessible name in render() so the label catches up.
@afercia
afercia force-pushed the fix/65852-media-attachment-aria-label branch from 9ff0009 to e36cc28 Compare October 10, 2026 13:53

@afercia afercia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Pushed a couple commits:

  • rebased on top of latest trunk
  • added @since tag
  • added QUnit tests

@afercia afercia added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Oct 10, 2026
@github-actions github-actions Bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Oct 10, 2026
wporg-sync pushed a commit that referenced this pull request Oct 10, 2026
- Makes sure the attachments visible label (and aria-label) is updated and it's not stale showing "uploading..." or "(no title)" for attachments whose models load after the view is created.
- Add QUnit tests.

Developed in #13053

Props sureshsornapudi09, archon810, rezwanshiblu1952, joedolson, afercia.
See #23562, #64883, #65438.
Fixes #65852.


git-svn-id: https://develop.svn.wordpress.org/trunk@64293 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 64293
GitHub commit: 9d65c0e

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Oct 10, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 10, 2026
- Makes sure the attachments visible label (and aria-label) is updated and it's not stale showing "uploading..." or "(no title)" for attachments whose models load after the view is created.
- Add QUnit tests.

Developed in WordPress/wordpress-develop#13053

Props sureshsornapudi09, archon810, rezwanshiblu1952, joedolson, afercia.
See #23562, #64883, #65438.
Fixes #65852.

Built from https://develop.svn.wordpress.org/trunk@64293


git-svn-id: http://core.svn.wordpress.org/trunk@63443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants