WIP: Filter – Select (enhanced, multiple): wrapper has role="listbox" with invalid children (aria-required-children)

Browser: Chrome 142 (Lighthouse 12 / axe)
OS: macOS
URL: client staging site, happy to share privately if needed.
Video: n/a, it’s a markup and accessibility issue. The Lighthouse output is below.

Bricks version: 2.4.6 (also seen on 2.4.2). I checked the changelogs from 2.4.3 to 2.4.6 and the 2.5-beta release notes and couldn’t find a fix.

Setup

  • A Filter – Select element on a query loop, using a taxonomy source
  • Enhanced select (Choices) turned on, with multiple selection allowed and search off
  • Placeholder set (“Anywhere”)

What happens
Once Choices has started up, the outer wrapper gets role="listbox". However, it contains the native <select> element and a role="button" element, and a listbox may only contain options or groups of options. Lighthouse and axe report aria-required-children on every page with an enhanced filter select, which costs about 5 points of the accessibility score per page.

The rendered markup, with the options trimmed:

<div class="bricks-choices" data-type="select-multiple" role="listbox"
     aria-haspopup="true" aria-expanded="false"
     aria-controls="h2dsl-listbox" aria-label="Anywhere">
  <div class="bricks-choices__inner">
    <select multiple hidden tabindex="-1" class="brxe-filter-select bricks-choices__input" ...>…</select>
    <div class="bricks-choices__list bricks-choices__list--multiple"></div>
    <div class="bricks-choices__placeholder bricks-choices__placeholder--multiple"
         tabindex="0" role="button" aria-haspopup="listbox"
         aria-expanded="false" aria-controls="h2dsl-listbox" aria-label="Anywhere">Anywhere</div>
  </div>
  <div class="bricks-choices__list bricks-choices__list--dropdown" aria-expanded="false">
    <div class="bricks-choices__list" role="listbox" id="h2dsl-listbox"
         aria-multiselectable="true" aria-label="Anywhere">
      <div role="option" ...>…</div>
    </div>
  </div>
</div>

Why it looks unintended

  • The page now has two listboxes: the wrapper, and the real one (#h2dsl-listbox) that holds the options.
  • The wrapper has aria-controls pointing at that inner listbox, which only makes sense if the wrapper is a trigger, not a listbox itself.
  • The placeholder role="button" already acts as the trigger, with aria-haspopup="listbox" and aria-controls.

Expected

  • No role="listbox" on the outer .bricks-choices wrapper. Either no role, or a proper combobox pattern on the trigger.
  • The inner #…-listbox keeps its role and options as they are.

Lighthouse output

aria-required-children: Element has children which are not allowed: select[aria-label], [role=button]
div.brxe-filter-select > div.bricks-choices

Workaround meanwhile (tested on 2.4.6)
After Choices has started up, remove role, aria-haspopup, aria-expanded and aria-controls from .bricks-choices. A MutationObserver keeps them off when Choices sets aria-expanded again on open. The placeholder role="button" and the inner #…-listbox stay as they are. Lighthouse accessibility goes from 95 to 100, and opening, selecting and submitting all still work.

var ATTRS = ['role', 'aria-haspopup', 'aria-expanded', 'aria-controls'];

function clean(el) {
  ATTRS.forEach(function (a) { el.removeAttribute(a); });
}

document.querySelectorAll('.bricks-choices').forEach(clean);

new MutationObserver(function (list) {
  list.forEach(function (m) {
    if (m.type === 'attributes' && m.target.classList.contains('bricks-choices')) {
      clean(m.target);
    }
    m.addedNodes && m.addedNodes.forEach(function (n) {
      if (n.nodeType === 1) {
        n.querySelectorAll('.bricks-choices').forEach(clean);
      }
    });
  });
}).observe(document.body, {
  subtree: true,
  childList: true,
  attributes: true,
  attributeFilter: ATTRS
});

Thanks!

Hi @AaronChaos

Thanks for the detailed report. We reproduced the invalid listbox structure issue.
We will work on a fix for it.