Make WordPress Core

Opened 4 months ago

Closed 4 months ago

#63973 closed defect (bug) (fixed)

Add Media Button missing aria-haspopup and aria-controls

Reported by: alh0319's profile alh0319 Owned by: joedolson's profile joedolson
Milestone: 6.9 Priority: normal
Severity: normal Version: 4.3
Component: Editor Keywords: has-patch commit
Focuses: accessibility Cc:

Description

In the classic editor, above the TinyMCE editor, there is an "Add Media" button which, when clicked, triggers the media library to open in a dialog.

This is the current code for that button:

<button type="button" id="insert-media-button" class="button insert-media add_media" data-editor="content"><span class="wp-media-buttons-icon"></span> Add Media</button>

Screen reader users are not warned that triggering this button will open a modal dialog.

For WCAG conformance the following attributes need to be added to this button:

  • aria-haspopup="dialog"
  • aria-controls referncing the ID of the modal being opened

For additional information see:

Change History (6)

#1 @joedolson
4 months ago

  • Owner set to joedolson
  • Status changed from new to accepted

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


4 months ago

#3 @joedolson
4 months ago

  • Component changed from TinyMCE to Editor
  • Milestone changed from Awaiting Review to 6.9
  • Version set to 4.3

I'm attributing this to version 4.3, when the control was changed to a button; though in practical truth I don't think that aria-haspopup was widely supported at the time.

See #32969.

This ticket was mentioned in PR #9932 on WordPress/wordpress-develop by @rishabhwp.


4 months ago
#4

  • Keywords has-patch added

#5 @joedolson
4 months ago

  • Keywords commit added

Tested. This has no significant potential for side-effects; the only plausible side-effect is in the case that an extender has added the id wp-media-modal somewhere in the editor admin.

There are no themes or plugins that return a positive test for that string in https://wpdirectory.net, so I think it's a safe bet that's not a significant concern.

#6 @joedolson
4 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 60786:

Editor: A11y: Set aria-haspopup on Add Media button.

Add the aria-haspopup attribute and aria-controls on the Add Media button in the classic editor, so that screen reader users are notified about the behavior of the button.

Props alh0319, rishabhwp, joedolson.
Fixes #63973.

Note: See TracTickets for help on using tickets.