Skip to content

Strip markup from post type and meta filter aria-labels - #4410

Merged
felipeelia merged 1 commit into
developfrom
fix/aria-label
Nov 11, 2026
Merged

felipeelia merged 1 commit into
developfrom
fix/aria-label

Conversation

@burhandodhy

Copy link
Copy Markdown
Contributor

Description of the Change

When "Display Term Count" is enabled on the Filter by Post Type or Filter by Metadata blocks, the visible label includes the count wrapped in a <span>. The same label was reused to build the link's aria-label, so the escaped markup ended up in the accessible name:

<a aria-label="Apply filter: Product &lt;span&gt;(18)&lt;/span&gt;" ...>

This change strips tags from the label before building the accessible label (both "Apply filter" and "Remove filter"), so screen readers announce Apply filter: Product (18). The visible label is unchanged and still renders the <span>. Labels customized through ep_facet_post_type_value_label / ep_facet_meta_value_label get the same treatment. The taxonomy facet already builds its accessible label from the plain term name, so it is not affected.

How to test the Change

  1. Enable the Filters feature and add a Filter by Post Type block and a Filter by Metadata block (with "Display Term Count" on) to a widget area.
  2. Visit a page where the blocks render (e.g. /shop/ or a search results page) and inspect a filter link.
  3. Before: aria-label="Apply filter: Product &lt;span&gt;(18)&lt;/span&gt;". After: aria-label="Apply filter: Product (18)".
  4. Select a filter and confirm the selected link reads Remove filter: Product (18).
  5. With "Display Term Count" off, the label is Apply filter: Product.

Changelog Entry

Fixed - Post type and metadata filter links no longer include HTML markup in their aria-label when term counts are displayed.

Credits

Props @burhandodhy

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

When Display Term Count is on, the visible label includes the count wrapped
in a <span>. That same label was used to build the link's aria-label, so the
escaped markup ended up in the accessible name, e.g.
"Apply filter: Product &lt;span&gt;(18)&lt;/span&gt;". Strip tags before
building the accessible label so screen readers announce
"Apply filter: Product (18)".
@burhandodhy burhandodhy added this to the 5.3.6 milestone Nov 11, 2026
@felipeelia
felipeelia merged commit 58290f6 into develop Nov 11, 2026
41 checks passed
@felipeelia
felipeelia deleted the fix/aria-label branch November 11, 2026 12:02
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