accessibility: make dropdowns accessible (#9475)
#### Motivation Improve accessibility of dropdowns. #### Before Dropdowns are not accessible. <img width="1219" alt="Screenshot 2025-01-09 at 10 00 36" src="https://github.com/user-attachments/assets/060198f8-a42f-408c-a39a-b83da55e23c4" /> #### Ater Dropdowns are accessible 
This commit is contained in:
@ -92,7 +92,11 @@ export const SingleRecordSelectMenuItemsWithSearch = ({
|
||||
<DropdownMenuSeparator />
|
||||
</>
|
||||
)}
|
||||
<DropdownMenuSearchInput onChange={handleSearchFilterChange} autoFocus />
|
||||
<DropdownMenuSearchInput
|
||||
onChange={handleSearchFilterChange}
|
||||
autoFocus
|
||||
role="combobox"
|
||||
/>
|
||||
{(dropdownPlacement?.includes('start') ||
|
||||
isUndefinedOrNull(dropdownPlacement)) && (
|
||||
<>
|
||||
|
||||
@ -37,6 +37,7 @@ export const CurrencyPickerDropdownSelect = ({
|
||||
value={searchFilter}
|
||||
onChange={(event) => setSearchFilter(event.target.value)}
|
||||
autoFocus
|
||||
role="combobox"
|
||||
/>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItemsContainer hasMaxHeight>
|
||||
|
||||
@ -136,6 +136,10 @@ export const Dropdown = ({
|
||||
<div
|
||||
ref={refs.setReference}
|
||||
onClick={handleClickableComponentClick}
|
||||
aria-controls={`${dropdownId}-options`}
|
||||
aria-expanded={isDropdownOpen}
|
||||
aria-haspopup={true}
|
||||
role="button"
|
||||
>
|
||||
{clickableComponent}
|
||||
</div>
|
||||
|
||||
@ -122,6 +122,8 @@ export const DropdownContent = ({
|
||||
<StyledDropdownContentContainer
|
||||
ref={floatingUiRefs.setFloating}
|
||||
style={dropdownMenuStyles}
|
||||
role="listbox"
|
||||
id={`${dropdownId}-options`}
|
||||
>
|
||||
<OverlayContainer>
|
||||
<DropdownMenu
|
||||
@ -138,9 +140,12 @@ export const DropdownContent = ({
|
||||
<StyledDropdownContentContainer
|
||||
ref={floatingUiRefs.setFloating}
|
||||
style={dropdownMenuStyles}
|
||||
role="listbox"
|
||||
id={`${dropdownId}-options`}
|
||||
>
|
||||
<OverlayContainer>
|
||||
<DropdownMenu
|
||||
id={dropdownId}
|
||||
className={className}
|
||||
width={dropdownMenuWidth ?? dropdownWidth}
|
||||
data-select-disable
|
||||
|
||||
@ -51,6 +51,7 @@ export const DropdownMenuItemsContainer = ({
|
||||
<StyledDropdownMenuItemsExternalContainer
|
||||
hasMaxHeight={hasMaxHeight}
|
||||
className={className}
|
||||
role="listbox"
|
||||
>
|
||||
{hasMaxHeight ? (
|
||||
<StyledScrollWrapper
|
||||
@ -76,6 +77,7 @@ export const DropdownMenuItemsContainer = ({
|
||||
<StyledDropdownMenuItemsExternalContainer
|
||||
hasMaxHeight={hasMaxHeight}
|
||||
className={className}
|
||||
role="listbox"
|
||||
>
|
||||
<StyledDropdownMenuItemsInternalContainer>
|
||||
{children}
|
||||
|
||||
@ -69,6 +69,9 @@ export const MenuItemSelect = ({
|
||||
selected={selected}
|
||||
disabled={disabled}
|
||||
hovered={hovered}
|
||||
role="option"
|
||||
aria-selected={selected}
|
||||
aria-disabled={disabled}
|
||||
>
|
||||
<MenuItemLeftContent LeftIcon={LeftIcon} text={text} />
|
||||
{selected && needIconCheck && <IconCheck size={theme.icon.size.md} />}
|
||||
|
||||
@ -40,6 +40,9 @@ export const MenuItemSelectAvatar = ({
|
||||
disabled={disabled}
|
||||
hovered={hovered}
|
||||
data-testid={testId}
|
||||
role="option"
|
||||
aria-selected={selected}
|
||||
aria-disabled={disabled}
|
||||
>
|
||||
<StyledMenuItemLeftContent>
|
||||
{avatar}
|
||||
|
||||
Reference in New Issue
Block a user