Skip to content

Commit

Permalink
feat: add a11y props for search and combobox components (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaharzil authored May 6, 2024
1 parent 4425821 commit b564e1b
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 43 deletions.
13 changes: 11 additions & 2 deletions packages/core/src/components/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import { StickyCategoryHeader } from "./components/StickyCategoryHeader/StickyCa
import { useItemsData, useKeyboardNavigation } from "./ComboboxHelpers/ComboboxHelpers";
import { getOptionId } from "./helpers";
import { ElementContent, SubIcon, VibeComponentProps, withStaticProps } from "../../types";
import { IComboboxCategoryMap, IComboboxItem, IComboboxOption } from "./components/ComboboxConstants";
import {
IComboboxCategoryMap,
IComboboxItem,
IComboboxOption,
COMBOBOX_LISTBOX_ID
} from "./components/ComboboxConstants";
import styles from "./Combobox.module.scss";

export interface ComboboxProps extends VibeComponentProps {
Expand Down Expand Up @@ -282,7 +287,7 @@ const Combobox: React.FC<ComboboxProps> & {
data-testid={dataTestId || getTestId(ComponentDefaultTestId.COMBOBOX, id)}
ellipsis={false}
>
<div className={styles.comboboxList} style={{ maxHeight: optionsListHeight }} role="listbox">
<div className={styles.comboboxList} style={{ maxHeight: optionsListHeight }}>
<Search
ref={inputRef}
value={filterValue}
Expand All @@ -297,6 +302,9 @@ const Combobox: React.FC<ComboboxProps> & {
autoFocus={autoFocus}
loading={loading}
searchIconName={searchIcon}
ariaExpanded={hasFilter || hasResults}
ariaHasPopup="listbox"
searchResultsContainerId={id ? `${id}-listbox` : COMBOBOX_LISTBOX_ID}
/>
{stickyCategories && <StickyCategoryHeader label={activeCategoryLabel} />}
<ComboboxItems
Expand All @@ -316,6 +324,7 @@ const Combobox: React.FC<ComboboxProps> & {
renderOnlyVisibleOptions={renderOnlyVisibleOptions}
maxOptionsWithoutScroll={maxOptionsWithoutScroll}
visualFocusItemIndex={visualFocusItemIndex}
id={id ? `${id}-listbox` : COMBOBOX_LISTBOX_ID}
/>
</div>
{hasFilter && !hasResults && !loading && renderNoResults()}
Expand Down
Loading

0 comments on commit b564e1b

Please sign in to comment.