Skip to content

Media: Fix ARIA labelling and list semantics in the media views - #13368

Open
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/media-a11y-dialog-name-list-role
Open

Media: Fix ARIA labelling and list semantics in the media views#13368
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/media-a11y-dialog-name-list-role

Conversation

@itzmekhokan

Copy link
Copy Markdown

The Edit attachment modal in the Media Library grid opens without an accessible name, and the attachments list is reported as structurally invalid because its items override the list-item role.

tmpl-media-modal labeled its role="dialog" element with a fixed media-frame-title ID that sat on the frame's heading container. In the grid that ID belongs to the manage frame's empty heading, and any page opening more than one media frame produces duplicates. The ID is now generated per modal instance and set on the frame's h1. Separately, the attachments ul gets role="group", since its li children carry role="checkbox" and ARIA in HTML only permits that when the list role changes too.

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: reproducing the violations in the browser, diagnosing the duplicate ID, and drafting the fix. All changes were reviewed and validated by me.


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.

The media modal labelled itself with a fixed `media-frame-title` ID that
was set on the frame's heading container. In the Media Library grid that
ID is claimed by the manage frame's empty heading, so the Edit attachment
dialog had no accessible name, and any page that opened more than one
media frame ended up with duplicate IDs.

Generate the ID on the modal instance, set it directly on the frame's H1
heading, and reference it from the dialog element.

Also set `role="group"` on the attachments list. Its `li` children carry
`role="checkbox"`, and ARIA in HTML only allows that if the role of the
list itself is changed as well.

Fixes #66025.
@github-actions

github-actions Bot commented Sep 2, 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 khokansardar, afercia.

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

@github-actions

github-actions Bot commented Sep 2, 2026

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 3, 2026

Copy link
Copy Markdown
Member

Thank you @itzmekhokan the new unique ID seem to work nicely.
I'd just wait for feedback from @joedolson to confirm the role=group for the attachments list is the most appropriate one. Also to consider whether it needs to be labeled, not sure because there is already a visually hidden heading before it.

Hint for testing:

  • Create a post and add a Classic block.
  • When editing the Classic block, click 'Add Media' in the TinyMCE editor toolbar.
  • That will give you access to a media modal dialog with all the frames like Add media, Create Gallery, Create audio playlist etc. so that all the media frames can be tested when the heading changes dynamically.

@afercia
afercia requested a review from joedolson September 3, 2026 08:39
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