Make WordPress Core

Opened 14 months ago

Closed 13 months ago

Last modified 8 months ago

#55530 closed enhancement (fixed)

Category archive links include description in a title attribute by default

Reported by: just0nequestion's profile just0nequestion Owned by: audrasjb's profile audrasjb
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: title-attribute good-first-bug has-patch commit add-to-field-guide
Focuses: accessibility Cc:

Description (last modified by sabernhardt)

As aria should help people that need assistive technology, having them to listen to a whole heap of crumbled words that come from a html structured category description isn't what this was intendend for.

<li class="cat-item cat-item-1 current-cat"><a aria-current="page" href="https://www.blog.com" title="Here comes everything from the category description with stipped html tags which results in a lot of words that don't give the user of assistive technology a benefit. It even disturbs him (when categories have long / formatted descriptions. The words here show up without formatting and created duplicate content on page">*</a>

Attachments (4)

55530.diff (1.0 KB) - added by andrija 14 months ago.
Default use_desc_for_title set to false (0), category walker will always create <a title=""> attribute with category name (default) or category description if use_desc_for_title is set to true (1)
55530.2.diff (1.0 KB) - added by andrija 14 months ago.
Replaced spaces with tabs
55530.3.diff (524 bytes) - added by andrija 14 months ago.
This diff only changes the default value of use_desc_for_title to false (0)
55530.4.diff (1.3 KB) - added by andrija 14 months ago.
Default use_desc_for_title set to false (0)

Download all attachments as: .zip

Change History (22)

#1 @sabernhardt
14 months ago

  • Component changed from General to Taxonomy
  • Description modified (diff)
  • Focuses accessibility added
  • Keywords needs-patch title-attribute added
  • Type changed from defect (bug) to enhancement
  • Version 5.9.2 deleted

Thanks for the report!

WordPress has removed many title attributes, but the wp_list_categories function still has use_desc_for_title true (1) by default. I don't think this should be the expected default.

#2 @joyously
14 months ago

Is it the aria or the title that is the problem?

#3 @just0nequestion
14 months ago

The problem is within the <a title="">

Thank you for taking notice!

#4 @sabernhardt
14 months ago

  • Summary changed from In widget area <a aria-current="page" title="shows whole category description when only cat_title should be shown - which breaks the intended benefit of aria (and creates duplicate content on the category archive)" to Category archive links include description in a title attribute by default

#5 @sabernhardt
14 months ago

  • Keywords good-first-bug added

#6 @andrija
14 months ago

Hello @sabernhardt, I'd like to tackle this as my first bug.

Can you help me brainstorm the best solution, please?

Currently, the default value of use_desc_for_title is 1.
If I set it to 0, then the HTML <a> tag will have no title attribute at all.

  • Should we remove that default arg, then we'll never have the <a> title attribute
  • Should we change the behavior of \src\wp-includes\class-walker-category.php:125 to simply use $category->name if use_desc_for_title is 1, but that simply sounds wrong
  • Should we add an } else { there so we always have the title attribute in the <a> tag, with the $category->description if use_desc_for_title is 1 and $category->name if use_desc_for_title is 0

I guess the last solution would work, what do you think?

@andrija
14 months ago

Default use_desc_for_title set to false (0), category walker will always create <a title=""> attribute with category name (default) or category description if use_desc_for_title is set to true (1)

@andrija
14 months ago

Replaced spaces with tabs

#7 @andrija
14 months ago

  • Keywords has-patch added; needs-patch removed

#8 @sabernhardt
14 months ago

Thanks for the patch!

I could have linked to #24766 to explain why many title attributes have been removed. Plus, the category name is already used in the link text, so adding the same in a title attribute would be redundant.

@andrija
14 months ago

This diff only changes the default value of use_desc_for_title to false (0)

#9 follow-up: @andrija
14 months ago

Ok, thank you for the additional information.

The latest diff changes the default value to false (0) which means no title attribute.

If someone needs the title they can change the $args value to true (1) and if they need to manipulate it there's a filter in the category Walker.

I guess this was the shortest possible diff .)

#10 in reply to: ↑ 9 @sabernhardt
14 months ago

  • Milestone changed from Awaiting Review to 6.0

I guess this was the shortest possible diff

Almost :) The docblock needs updating as well (it says "Default 1.")

#11 @sabernhardt
14 months ago

  • Keywords needs-refresh added

@andrija
14 months ago

Default use_desc_for_title set to false (0)

#12 @sabernhardt
14 months ago

  • Keywords needs-refresh removed
  • Milestone changed from 6.0 to 6.1

#14 @audrasjb
13 months ago

  • Owner set to audrasjb
  • Status changed from new to reviewing

Thanks for the patch!
I added a PR to make sure it passes Core unit tests.
Self assigning for final review/commit.

#15 @audrasjb
13 months ago

  • Keywords commit added

All checks have passed. Looks good to me.

#16 @audrasjb
13 months ago

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

In 53392:

Taxonomy: Set use_desc_for_title to false by default in wp_list_categories()

This change removes the default title attribute of category links returned by wp_list_categories(), for better accessibility.

Props just0nequestion, joyously, andrija, audrasjb, sabernhardt.
Fixes #55530.
See #24766.

#18 @milana_cap
8 months ago

  • Keywords add-to-field-guide added
Note: See TracTickets for help on using tickets.