ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

[ui5-search-item]: role="option" element contains interactive children (buttons), violating ARIA listbox/option semantics

Open mastanshaikk opened this issue 1 week ago • 2 comments

Bug Description

In SearchItemTemplate.tsx, the root <li> of ui5-search-item is rendered with role="option" (line 20) but contains interactive/focusable children:

  • the "delete" ui5-button (rendered when deletable is set), and
  • the actions slot, which is intended to hold interactive controls (e.g. buttons).

These items are placed inside a ui5-list configured with accessibleRole={ListAccessibleRole.ListBox} (SearchPopoverTemplate.tsx), so the accessibility tree is role="listbox" → role="option" → interactive button.

Per the WAI-ARIA specification, an element with role="option" must not contain interactive (focusable) descendants. option is only an allowed child of listbox, and the listbox/option pattern expects options to be non-interactive leaf nodes operated through the listbox's single-tab-stop + arrow-key model. Nesting buttons (or any focusable control) inside an option:

  • produces an invalid/ambiguous accessibility tree,
  • causes inconsistent exposure of the nested controls across assistive technologies (screen readers may not announce or may mis-handle them), and
  • the nested controls are not reliably operable via the listbox keyboard interaction model.

The same concern applies to SearchItemShowMoreTemplate.tsx, which also uses role="option".

Affected Component

ui5-search-item (ui5-search) — packages/fiori/src/SearchItemTemplate.tsx (line 20); see also packages/fiori/src/SearchItemShowMoreTemplate.tsx.

Expected Behaviour

The accessibility semantics of a search item should be valid. An element exposed as role="option" should not contain interactive/focusable descendants. The structure/roles should be reworked so that items containing actions (delete button, actions slot) map to an ARIA pattern that legitimately allows interactive children, while remaining keyboard- and screen-reader-operable.

Steps to Reproduce

  1. Render a ui5-search with suggestion items.
  2. Add a ui5-search-item with deletable set (and/or content in the actions slot).
  3. Open the suggestions popover and inspect the accessibility tree (e.g. Chrome DevTools → Accessibility pane).
  4. Observe role="listbox" → role="option" where the option contains a focusable button, which is not permitted by the ARIA option role.

Suggested Fix

The root cause is that the listbox/option widget pattern forbids interactive descendants. There are two viable ways to fix it; the right choice depends on whether per-item selection state must remain exposed to assistive technologies.

Option 1 — switch option → listitem (and listbox → list)

listitem is an ARIA document-structure role (not a widget role), so — unlike option — it permits interactive descendants such as the delete button and the actions slot. This is the simplest change and reuses the component's existing public API:

  • Container (SearchPopoverTemplate.tsx): set the List accessible role to ListAccessibleRole.List (→ role="list") instead of ListBox.
  • SearchItemTemplate.tsx: change the root <li> from role="option" to role="listitem". The nested ui5-button (delete) and actions slot then become valid.
  • SearchItemShowMoreTemplate.tsx: likewise role="listitem".

Trade-off to be aware of: aria-selected is not a supported state on role="listitem" (it is only valid on option, row, gridcell, treeitem, tab, …). The current aria-selected={this.selected} binding (line 19) would therefore need to be removed, and per-item selection state would no longer be conveyed through that attribute.

  • If the item's selected state is effectively a visual highlight of the active suggestion, this is acceptable — the active suggestion can instead be communicated to screen readers via aria-activedescendant on the role="searchbox" input (the input currently exposes aria-controls="ui5-search-list" only), which also aligns better with how a suggestion popup is announced.
  • If selected carries real selection semantics that must be exposed, prefer Option 2.

Option 2 — migrate the popup to a single-column grid (preserves selection)

The WAI-ARIA Authoring Practices (APG) recommend the grid pattern when the items of a listbox/combobox popup must contain interactive elements, because a grid allows interactive controls inside its cells and retains aria-selected:

  • Container (SearchPopoverTemplate.tsx): expose it as role="grid" instead of ListAccessibleRole.ListBox, with an accessible name via aria-label.
  • SearchItemTemplate.tsx: change the root <li> from role="option" to role="row" (keep aria-selected — it is valid on row). Wrap the main content in a role="gridcell", and place each interactive control (the actions slot and the delete ui5-button) in its own role="gridcell".
  • SearchItemShowMoreTemplate.tsx: becomes a role="row" whose button sits in a role="gridcell".
  • Keyboard: extend the existing roving-tabindex handling so Up/Down move between rows and Left/Right (or Tab within a row, per the grid pattern) move focus to the interactive cells within the focused row.

Recommendation

  • Use Option 1 (listitem) if selection is visual/active-item only — it is the smallest, lowest-risk change and makes the interactive children valid immediately.
  • Use Option 2 (grid) if the selected state must stay exposed to assistive technologies, since it keeps aria-selected while still permitting the embedded controls.

References: WAI-ARIA APG — Combobox pattern (note on popups containing interactive elements), Listbox pattern, and Grid pattern; and the WAI-ARIA spec for aria-selected supported roles.

Priority

Medium (Accessibility issue)

Environment Info

  • UI5 Web Components Version: 2.29.0 (also present on main / latest)
  • Browser: Browser-agnostic (semantic/ARIA issue in the rendered DOM; verified in Chrome / Edge)
  • Operating System: Windows 11

Additional Context

This is a semantic accessibility (WAI-ARIA conformance) issue rather than a visual/functional regression. It affects the correctness of the exposed accessibility tree for search suggestions that include a delete action or custom actions.

Declaration

  • [x] I'm not disclosing any internal or sensitive information.

mastanshaikk avatar Nov 21 '26 20:11 mastanshaikk

Hello @UI5/ui5-team-ctr-ril ,

Please check the reported issue as it seems to be legit.

Best Regards, Nikolay Hristov

NHristov-sap avatar Nov 23 '26 08:11 NHristov-sap

Hello @mastanshaikk,

Thank you for raising this and for the detailed analysis!

We've reviewed the issue internally and discussed it with our responsible designer and the central accessibility team. The feedback confirms that the concern you raised is valid and relevant from an accessibility perspective. However, the current behavior is in line with our existing specification — so a fix cannot be shipped as a simple bug correction. Any change here would be an update to the accessibility specification of the Search component, which requires the following steps first:

  1. Specification update on the design side — including analysis, discussion, and accessibility testing led by the central ACC team
  2. Implementation on our side — only after the updated specification is finalized.

This means we are not able to address this as a GitHub issue fix. We will instead track it as a Backlog Item (BLI) in our internal planning, so it goes through the proper design and review process before implementation begins. Thank you for your patience — we know this is not the quick turnaround you may have hoped for, but we want to make sure the solution is well-defined and doesn't introduce regressions in other areas.

Kind Regards, Niya

niyap avatar Nov 26 '26 07:11 niyap