Media: Refresh attachment tile aria-label when model data loads - #13053
Media: Refresh attachment tile aria-label when model data loads#13053sornapudisuresh wants to merge 1 commit into
Conversation
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.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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.Attachmentcomputesaria-labelonly inattributes(), and Backbone evaluates that once during_ensureElement(). Core (and Gutenberg) often create tiles viaAttachment.get( id )+fetch(), so the label is computed from empty model data and never updates when the model later receives a title — even thoughrender()re-runs on modelchange.This is distinct from #65438 / [62892], which only changes which fallback string is used for a titleless model.
Fix
getAriaLabel().aria-labelat the end ofrender()once the model has data.attributes(e.g.Attachment.Details, see #47458) so we do not add inappropriate attributes there.aria-checkedalone so selection state fromupdateSelect()is not clobbered.Testing instructions
uploading…/(no title)).(no title), and in-progress uploads still showuploading….aria-labelattributes 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.