Skip to content

fix: give facet options search input an accessible name by default (#692) - #693

Open
chrissnyder2337 wants to merge 4 commits into
yext:mainfrom
chrissnyder2337:fix/692-facet-options-search-accessible-name
Open

fix: give facet options search input an accessible name by default (#692)#693
chrissnyder2337 wants to merge 4 commits into
yext:mainfrom
chrissnyder2337:fix/692-facet-options-search-accessible-name

Conversation

@chrissnyder2337

@chrissnyder2337 chrissnyder2337 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #692.

Problem

The options-search input rendered by FilterGroup (used by StandardFacet, NumericalFacet, and StaticFilters) only received an associated <label> when showOptionsSearchInputLabel was enabled, and enabling it also displayed the label visually. One prop controlled both the semantic association and the visual presentation.

With the prop off (the default), the input's accessible name fell back to the shared "Search here..." placeholder: identical for every searchable facet on the page, and gone once the user typed.

Approach

This implements proposed solution 1 from the issue, plus solution 3.

FilterGroup now always generates the label text and always associates it with the input via htmlFor/id. showOptionsSearchInputLabel only controls whether the label is visible, through a new visuallyHiddenLabel prop on Filters.SearchInput that renders it with sr-only.

Every searchable facet therefore gets a persistent, distinguishable accessible name ("Search Products Options", "Search Price Options") with no visible label row and no consumer configuration. This also resolves the auto-rendered <Facets> case from the issue, where the CSS workaround was not available at all.

Changes

  • Filters.SearchInput: new visuallyHiddenLabel prop. When set, the label renders with sr-only, or with labelClassName if the consumer supplies one, so consumers whose stylesheet does not define an unprefixed sr-only can hide it another way.
  • FilterGroup: label text is always generated; showOptionsSearchInputLabel maps to visuallyHiddenLabel={!showOptionsSearchInputLabel}.
  • FacetsProps.showOptionsSearchInputLabel (solution 3): shows the label across auto-rendered facets, overridable per child facet. Facet props passed as undefined now count as unspecified, so they inherit the Facets value rather than erasing it.
  • SearchI18nextProvider: added filterGroupSearchInputLabel to the translationKeys union. The key already existed in all 31 locale files, but overriding it through translationOverrides was a type error.

Layout

The hidden label renders after the input. CollapsibleSection defaults to space-y-3, whose compiled rule is .space-y-3>:not([hidden])~:not([hidden]){margin-top:.75rem}. A label in front of the input would make the input a non-first child and give it a 0.75rem top margin it did not previously have, even though an sr-only label (position: absolute) contributes no height. Keeping the input first leaves the default rendering pixel-identical to v3.2.1. htmlFor preserves the association regardless of order, and a test pins the sibling order.

Backwards compatibility

No breaking changes. showOptionsSearchInputLabel still defaults to false and still shows the label when true. The workaround documented in the issue (showOptionsSearchInputLabel plus customCssClasses={{ searchInputLabel: 'sr-only' }}) keeps working.

Snyder, Chris added 4 commits July 30, 2026 13:18
…ext#692)

The options search input rendered by FilterGroup only received an
associated label when showOptionsSearchInputLabel was enabled, so by
default its accessible name fell back to the shared "Search here..."
placeholder.

The label text is now always generated and associated with the input;
showOptionsSearchInputLabel only controls whether it is visible, via a
new visuallyHiddenLabel prop on Filters.SearchInput. FacetsProps also
accepts showOptionsSearchInputLabel so auto-rendered facets can show
the label without declaring a child override per facet.
Rendering the visually hidden label ahead of the input made the input a
non-first child of the surrounding space-y-3 container, which gave it a
0.75rem top margin that it did not have when no label was rendered. The
hidden label now follows the input instead, leaving the default layout
unchanged.
The key exists in every locale file but was missing from the
translationKeys union, so overriding the facet options search input
label through SearchI18nextProvider was a type error.
…t facet props

The hidden label now uses customCssClasses.searchInputLabel when one is
given and falls back to sr-only, so a consumer whose stylesheet lacks
sr-only can hide it another way.

Facet props passed as undefined no longer erase the values Facets
supplies, matching what absent props do.
@chrissnyder2337
chrissnyder2337 requested a review from a team as a code owner July 30, 2026 19:38
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 83.447% (-1.3%) from 84.727% — chrissnyder2337:fix/692-facet-options-search-accessible-name into yext:main

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.

Accessibility bug: facet options-search input only gets an accessible name when the visible label is enabled (showOptionsSearchInputLabel)

2 participants