Skip to content

Commit

Permalink
Fix #7643: Dropdown add aria label Option List (#7655)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jan 28, 2025
1 parent 08db110 commit ec81f40
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions components/lib/api/Locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ let locales = {
jumpToPageDropdownLabel: 'Jump to Page Dropdown',
jumpToPageInputLabel: 'Jump to Page Input',
lastPageLabel: 'Last Page',
listLabel: 'Option List',
listView: 'List View',
moveAllToSource: 'Move All to Source',
moveAllToTarget: 'Move All to Target',
Expand Down
4 changes: 4 additions & 0 deletions components/lib/api/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,10 @@ export interface LocaleOptions {
* Rotate Left
*/
rotateLeft?: string;
/**
* Options List Label
*/
listLabel?: string;
};
}

Expand Down
12 changes: 7 additions & 5 deletions components/lib/dropdown/DropdownPanel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { localeOption, PrimeReactContext } from '../api/Api';
import { ariaLabel, localeOption, PrimeReactContext } from '../api/Api';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useMergeProps } from '../hooks/Hooks';
import { SearchIcon } from '../icons/search';
Expand Down Expand Up @@ -158,11 +158,11 @@ export const DropdownPanel = React.memo(

const createFilterClearIcon = () => {
if (props.showFilterClear && props.filterValue) {
const ariaLabel = localeOption('clear');
const ariaLabelFilterClear = localeOption('clear');
const clearIconProps = mergeProps(
{
className: cx('filterClearIcon'),
'aria-label': ariaLabel,
'aria-label': ariaLabelFilterClear,
onClick: () => props.onFilterClearIconClick(() => DomHandler.focus(filterInputRef.current))
},
getPTOptions('filterClearIcon')
Expand Down Expand Up @@ -261,7 +261,8 @@ export const DropdownPanel = React.memo(
ref: options.contentRef,
style: options.style,
className: classNames(options.className, cx('list', { virtualScrollerProps: props.virtualScrollerOptions })),
role: 'listbox'
role: 'listbox',
'aria-label': ariaLabel('listLabel')
},
getPTOptions('list')
);
Expand All @@ -286,7 +287,8 @@ export const DropdownPanel = React.memo(
const listProps = mergeProps(
{
className: cx('list'),
role: 'listbox'
role: 'listbox',
'aria-label': ariaLabel('listLabel')
},
getPTOptions('list')
);
Expand Down
1 change: 1 addition & 0 deletions components/lib/hooks/useLocale.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ let locales = {
jumpToPageDropdownLabel: 'Jump to Page Dropdown',
jumpToPageInputLabel: 'Jump to Page Input',
lastPageLabel: 'Last Page',
listLabel: 'Option List',
listView: 'List View',
moveAllToSource: 'Move All to Source',
moveAllToTarget: 'Move All to Target',
Expand Down

0 comments on commit ec81f40

Please sign in to comment.