Make WordPress Core

Opened 4 months ago

Closed 2 months ago

Last modified 2 months ago

#62861 closed defect (bug) (fixed)

Consider removing title attributes from Classic Editor scripts

Reported by: sabernhardt's profile sabernhardt Owned by: joedolson's profile joedolson
Milestone: 6.8 Priority: low
Severity: normal Version:
Component: TinyMCE Keywords: title-attribute has-patch commit
Focuses: accessibility Cc:

Description (last modified by joedolson)

Related: #24766

The WordPress script adds title attributes to the placeholder images for style, script, More and Next Page tags.

  • The More tag and Next Page tag have an empty alt but use a title attribute (like alt="" title="Read more..."). The title text theoretically could be assigned as the alt, though the tooltip could help in cases of low color contrast.
  • The WP_More command has a similar pattern for More and Next Page tags, but I did not find how—or if—that is used.
  • Style and script tags have redundant title attributes, matching their alt text (like alt="<style>" title="<style>"). However, the tooltip is the only way to distinguish these two placeholders visually (unless it's worth replacing the transparent GIF with something like a text-based SVG).

Additional title attributes are in other (external) TinyMCE-related scripts:

Attachments (2)

placeholders-2020-default-background.png (31.5 KB) - added by sabernhardt 4 months ago.
placeholder images, showing the style tag tooltip, with Twenty Twenty's default background color
placeholders-2020-black-background.png (29.3 KB) - added by sabernhardt 4 months ago.
placeholder images, with a black background color

Download all attachments as: .zip

Change History (22)

@sabernhardt
4 months ago

placeholder images, showing the style tag tooltip, with Twenty Twenty's default background color

@sabernhardt
4 months ago

placeholder images, with a black background color

#1 @sabernhardt
4 months ago

This is what I entered in the Classic Editor's Text mode (now "Code" tab) to get the placeholder images (screenshots use WordPress 6.7.1).

More tag

<!--more-->

More tag with custom text

<!--more More tag with custom text-->

Page break tag

<!--nextpage-->

Style tag

<style>.style{}</style>

Script tag

<script>console.log('<script>');</script>

#2 @sabernhardt
4 months ago

  • Description modified (diff)

#3 @sabernhardt
4 months ago

  • Description modified (diff)

#4 @joedolson
4 months ago

  • Milestone changed from Awaiting Review to 6.8
  • Owner set to joedolson
  • Status changed from new to accepted

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


3 months ago

#6 @sabernhardt
3 months ago

  • Description modified (diff)
  • Type changed from enhancement to defect (bug)

As discussed in today's bug scrub, this ticket should focus on only the wordpress/plugin.js placeholder images. Any revision or replacement for the external plugins could have its own ticket.

#7 @audrasjb
3 months ago

  • Keywords needs-patch added

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


3 months ago
#8

  • Keywords has-patch added; needs-patch removed

Trac ticket: 62861

Removes redundant title attributes from Classic Editor placeholder images and moves tooltip text to alt attributes for better accessibility.

The Classic Editor uses placeholder images for special elements (More tag, Next Page tag, Style/Script tags). Currently:

More/Next Page tags have empty alt but use the title for tooltips
Style/Script tags have redundant title attributes that duplicate their alt text

This causes accessibility issues as:

Screen readers may handle title attributes inconsistently
Empty alt attributes with title text don't follow accessibility best practices
Redundant attributes create unnecessary duplication

This PR:

Moved tooltip text from title to alt for More and Next Page tags
Removed redundant title attributes from Style/Script tag placeholders
Maintained all existing functionality and visual indicators through CSS classes

#9 @abcd95
3 months ago

Hi @sabernhardt, Thanks for raising this.

I have created a PR in an attempt to fix this, please take a look at your convenience and let me know if it tests well for you.

#10 @joedolson
3 months ago

  • Description modified (diff)

The PR tests fine; but I'm bothered by the fact that there's no distinction between the script img and the style image for sighted users now. The title attribute only provided assistance for some use cases, but it was *something*.

If we added CSS generated content on the placeholder wrapper or override the background image on .mce-object we might be able to improve this. But I think being able to see that the replacement is for a style or a script tag is necessary.

#11 @sabernhardt
3 months ago

I gave suggestions on the PR to override the background image for the style and script. Pseudo-elements do not work with images, and my earlier suggestion of a text-based SVG could be significantly larger than 20 by 20 pixels.

#12 @joedolson
3 months ago

I was suggestion a pseudo-element on the wrapper around the image, for what it's worth; but will look at the PR suggestions. A larger image would definitely be desirable.

#13 @sabernhardt
3 months ago

The mce-object images do not have a wrapper.

If some 20-by-20 images are good enough, they would be least disruptive. If the new images are wider than they are tall, they would need to enforce the height because wp-content.css and some themes set img height to auto in the editor (Twenty Twenty uses high specificity).

@abcd95 commented on PR #8263:


3 months ago
#14

https://github.com/user-attachments/assets/bc338f06-45c4-4a65-ac25-cf79c23f0563

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


2 months ago

@abcd95 commented on PR #8263:


2 months ago
#16

Hey @sabernhardt, Thanks for reviewing the PR.

Now that the changes look good to you, shall I go ahead and make the changes in the other places as you suggested in the ticket 62861?

@sabernhardt commented on PR #8263:


2 months ago
#17

shall I go ahead and make the changes in the other places...?

No, leave the external libraries as they are.

#18 @joedolson
2 months ago

  • Keywords commit added; 2nd-opinion removed

This is looking and testing well; I think it's good to go.

#19 @joedolson
2 months ago

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

In 60007:

TinyMCE: A11y: Remove title attributes and improve placeholders.

Shifts the title attribute on more and page-break placeholder images to alt, moves the title attribute to alt on the style and script placeholders and replaces the images to differentiate between CSS and JS content.

Props sabernhardt, abcd95, joedolson.
Fixes #62861.

@abcd95 commented on PR #8263:


2 months ago
#20

Merged in the Changeset [60007]

Note: See TracTickets for help on using tickets.