Skip to content

The open alternative to Salesforce, designed for AI.

accessibility: make dropdowns accessible (#9475)

Malo Marrec7126ec5ae7ad
diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/components/SingleRecordSelectMenuItemsWithSearch.tsx b/packages/twenty-front/src/modules/object-record/relation-picker/components/SingleRecordSelectMenuItemsWithSearch.tsx
index a971eecff28..1b9e1c3787f 100644
--- a/packages/twenty-front/src/modules/object-record/relation-picker/components/SingleRecordSelectMenuItemsWithSearch.tsx
+++ b/packages/twenty-front/src/modules/object-record/relation-picker/components/SingleRecordSelectMenuItemsWithSearch.tsx
@@ -92,7 +92,11 @@ export const SingleRecordSelectMenuItemsWithSearch = ({
<DropdownMenuSeparator />
</>
)}
- <DropdownMenuSearchInput onChange={handleSearchFilterChange} autoFocus />
+ <DropdownMenuSearchInput
+ onChange={handleSearchFilterChange}
+ autoFocus
+ role="combobox"
+ />
{(dropdownPlacement?.includes('start') ||
isUndefinedOrNull(dropdownPlacement)) && (
<>
diff --git a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownSelect.tsx b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownSelect.tsx
index 18891ea4b40..14031684e3c 100644
--- a/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownSelect.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/internal/currency/components/CurrencyPickerDropdownSelect.tsx
@@ -37,6 +37,7 @@ export const CurrencyPickerDropdownSelect = ({
value={searchFilter}
onChange={(event) => setSearchFilter(event.target.value)}
autoFocus
+ role="combobox"
/>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer hasMaxHeight>
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx
index 230d4152b62..ee55b31c1dd 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/Dropdown.tsx
@@ -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>
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx
index 3c2d2ea0ae0..acbae17556e 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownContent.tsx
@@ -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
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenuItemsContainer.tsx b/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenuItemsContainer.tsx
index edcfd5e75e6..4de0530e88c 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenuItemsContainer.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/components/DropdownMenuItemsContainer.tsx
@@ -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}
diff --git a/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelect.tsx b/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelect.tsx
index 98f8eb7157a..211b8452afc 100644
--- a/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelect.tsx
+++ b/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelect.tsx
@@ -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} />}
diff --git a/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelectAvatar.tsx b/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelectAvatar.tsx
index 4df9e280084..cbc748e1f99 100644
--- a/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelectAvatar.tsx
+++ b/packages/twenty-ui/src/navigation/menu-item/components/MenuItemSelectAvatar.tsx
@@ -40,6 +40,9 @@ export const MenuItemSelectAvatar = ({
disabled={disabled}
hovered={hovered}
data-testid={testId}
+ role="option"
+ aria-selected={selected}
+ aria-disabled={disabled}
>
<StyledMenuItemLeftContent>
{avatar}