Skip to content

Selector's trigger has no accessible name, and its role changes with hasSearch #4450

Open

Description

@anandubey

Summary

Selector's trigger button has no accessible name, and the markup it renders differs depending on hasSearch in a way that makes it impossible to target by role in either case.

Verified against @astryxdesign/[email protected] in Chromium, with label supplied through the component's own prop.

What renders

Two Selectors on the same page, both given a label. Read off the trigger <button>:

hasSearch role aria-label aria-labelledby text content
absent combobox null null the placeholder
true (none) null null the placeholder

Why each is a problem

Without hasSearch the trigger is <button role="combobox">. combobox is not a name-from-content role, so the placeholder text does not name it, and with no aria-label or aria-labelledby the accessible name computes to empty. A screen reader announces "collapsed, combobox" with no indication of which field it is. The visible label is rendered as a sibling element that is not associated with the control.

With hasSearch the same component renders a plain <button> with no role. That is name-from-content, so it does get a name — but the name is the placeholder ("Select a branch…"), not the label. Better than empty, still not the field's name, and it also loses the combobox role that conveys the control's behaviour.

Expected

The value passed to label should name the trigger in both shapes — via aria-labelledby pointing at the rendered label, or aria-label when the label is visually hidden — and the role should not depend on whether a search box is enabled.

Impact

On a form of several Selectors, every one announces identically. It also means neither getByRole('button', { name }) nor getByRole('combobox', { name }) matches the trigger, so automated tests and any assistive-tech user hit the same wall: consumers end up adding their own data-* hook to locate it, which does nothing for screen-reader users.

Reproduction

<Selector label="CLI" options={options} value={value} onChange={onChange} />
<Selector label="Branch" options={options} value={value} onChange={onChange} hasSearch />

Inspect either trigger: no aria-label, no aria-labelledby. Compare the role attribute between the two.

Activity

  1. cixzhang commented on Jul 28, 2026

    @cixzhang
    Contributor

    Tracked in the accessibility program tracker: #4475

  2. cixzhang commented on Jul 28, 2026

    @cixzhang
    Contributor

    Tracked in the accessibility program tracker: #4475

  3. added a commit that references this issue on Jul 31, 2026
  4. gonzoblasco commented on Jul 31, 2026

    @gonzoblasco
    Contributor

    Fixed in #4604 — the trigger button now references the Field label via aria-labelledby, so the accessible name resolves to the label prop in both hasSearch modes.

  5. added 2 commits that reference this issue on Aug 3, 2026
  6. duytbp commented on Oct 30, 2026

    @duytbp
    Contributor

    Two more effects of the role-less hasSearch trigger, still on main (14fc587) and in 0.7.4, for Selector and MultiSelector (#6991 gave only ComplexSelector role="combobox"):

    • The chosen value is not exposed. Since fix(#4450): give Selector trigger an accessible name via aria-labelledby #4604 the trigger is named by aria-labelledby pointing at the field label (Selector.tsx:1930), and with no role (Selector.tsx:2030) it is a plain button, so its content (the selected option) is neither its name nor a value. A screen reader hears "Fruit, button" with no "Apple". Without hasSearch the same Selector is a combobox whose value is "Apple".
    • aria-required is dropped. aria-required is not supported on button, so Chromium does not expose it. With an explicit isRequired the label's "Required" text still reaches the name, but under FormLayout defaultOptionality="required" the trigger is just "Fruit", while the non-search Selector next to it reports required: true. MultiSelector has the same two lines (MultiSelector.tsx:2461-2462, :2637).
    import {useState} from 'react';
    import {FormLayout, Selector} from '@astryxdesign/core';
    
    const options = [
      {value: 'apple', label: 'Apple'},
      {value: 'banana', label: 'Banana'},
    ];
    
    export function Repro() {
      const [value, setValue] = useState<string | undefined>('apple');
      return (
        <FormLayout defaultOptionality="required">
          <Selector label="Fruit" options={options} value={value} onChange={setValue} hasSearch />
          <Selector label="Plain" options={options} value={value} onChange={setValue} />
        </FormLayout>
      );
    }

    Chromium 156 accessibility tree: button "Fruit" (no value, no required) and combobox "Plain", value "Apple", required: true. Giving the search trigger role="combobox" too, as #6991 did, would fix both.

  7. gonzoblasco commented on Nov 3, 2026

    @gonzoblasco
    Contributor

    My 31 July comment above said this was fixed. It wasn't, and that comment is wrong. #4604 was closed unmerged: the reviewer's point stands — the native <label for> association already names the trigger, so the explicit aria-labelledby added nothing — and nothing in that PR ever touched required or value. The issue should not have been reported as closed. Both effects duytbp lists are still on main (aa4bd1d), at Selector.tsx:2111 and MultiSelector.tsx:2665, and I can reproduce them from the repro above.

    A third one, same root cause, and worth fixing in the same patch: with renderTrigger, MultiSelector cannot be repaired by the caller at all. MultiSelectorRenderTriggerProps hands back aria-haspopup, aria-expanded, aria-controls, aria-busy and aria-readonly — but no role, no aria-required, no aria-disabled. ComplexSelectorRenderTriggerProps gained all three in #6991, so a caller-owned control there can be a combobox; here it has to guess. Whatever you decide about the trigger role, the handoff should carry the same set.

    On the fix itself, role="combobox" on the search trigger as #6991 did is the right end state, but it is not a one-line change, and I don't think it should be presented as one. #3402 (ac17c7fc2) deliberately removed that role — "the popup's search input is the combobox … the trigger is a plain button that opens the listbox — not a second combobox" — and the decision is pinned in five places:

    • Selector/__tests__/Combobox.a11y.states.ts:122 — the Selector trigger with hasSearch exclusion
    • Selector/Selector.test.tsx:222, :794, :1119, :1635 — every hasSearch test locates the trigger as getByRole('button'), three of them with the comment "the trigger is a plain button, not a combobox"
    • Selector/__tests__/SelectorListboxName.a11y.chromium.spec.ts:43 — "The searchable trigger is a plain button until the list opens"

    ARIA 1.2 only says the value belongs to the text input in an editable combobox; it doesn't forbid a second combobox, but it doesn't bless this one either. So the choice between "make the trigger a combobox" and "keep #3402's model and expose value/required another way" is a design decision for whoever owns that record, not something the bug report settles.

    Whichever way it goes, required is the one that bites hardest today: under FormLayout defaultOptionality="required" the searchable trigger reports nothing at all, while the plain selector beside it reports required: true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions