Skip to content

Commit

Permalink
Fix primefaces#3263: Datatable aria label fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Sep 8, 2022
1 parent 21282ee commit d8b4052
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions components/lib/api/Locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let locales = {
equals: 'Equals',
notEquals: 'Not equals',
noFilter: 'No Filter',
filter: 'Filter',
lt: 'Less than',
lte: 'Less than or equal to',
gt: 'Greater than',
Expand Down
18 changes: 8 additions & 10 deletions components/lib/datatable/ColumnFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ export const ColumnFilter = React.memo((props) => {
];
};

const filterLabel = () => {
return localeOption('filter');
};

const noFilterLabel = () => {
return localeOption('noFilter');
};
Expand Down Expand Up @@ -450,12 +454,9 @@ export const ColumnFilter = React.memo((props) => {
'p-column-filter-menu-button-open': overlayVisibleState,
'p-column-filter-menu-button-active': hasFilter()
});
const label = filterLabel();

return (
<button ref={iconRef} type="button" className={className} aria-haspopup aria-expanded={overlayVisibleState} onClick={toggleMenu} onKeyDown={onToggleButtonKeyDown}>
<span className="pi pi-filter-icon pi-filter"></span>
</button>
);
return <Button ref={iconRef} type="button" icon="pi pi-filter-icon pi-filter" className={className} aria-haspopup aria-expanded={overlayVisibleState} onClick={toggleMenu} onKeyDown={onToggleButtonKeyDown} aria-label={label} />;
}

return null;
Expand All @@ -466,12 +467,9 @@ export const ColumnFilter = React.memo((props) => {
const className = classNames('p-column-filter-clear-button p-link', {
'p-hidden-space': !hasRowFilter()
});
const clearLabel = clearButtonLabel();

return (
<button className={className} type="button" onClick={clearFilter}>
<span className="pi pi-filter-slash"></span>
</button>
);
return <Button ref={iconRef} type="button" icon="pi pi-filter-slash" className={className} onClick={clearFilter} aria-label={clearLabel} />;
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ export const Dropdown = React.memo(
const iconClassName = classNames('p-dropdown-trigger-icon p-clickable', props.dropdownIcon);

return (
<div className="p-dropdown-trigger" role="button" aria-haspopup="listbox" aria-expanded={overlayVisibleState}>
<div className="p-dropdown-trigger" role="button" aria-haspopup="listbox" aria-expanded={overlayVisibleState} aria-label={props.placeholder || props.ariaLabel}>
<span className={iconClassName}></span>
</div>
);
Expand Down
4 changes: 3 additions & 1 deletion components/lib/paginator/RowsPerPageDropdown.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as React from 'react';
import { localeOption } from '../api/Api';
import { Dropdown } from '../dropdown/Dropdown';
import { ObjectUtils } from '../utils/Utils';

export const RowsPerPageDropdown = React.memo((props) => {
const hasOptions = props.options && props.options.length > 0;
const options = hasOptions ? props.options.map((opt) => ({ label: String(opt), value: opt })) : [];
const element = hasOptions ? <Dropdown value={props.value} options={options} onChange={props.onChange} appendTo={props.appendTo} disabled={props.disabled} /> : null;
const ariaLabel = localeOption('choose');
const element = hasOptions ? <Dropdown value={props.value} options={options} onChange={props.onChange} appendTo={props.appendTo} disabled={props.disabled} placeholder={ariaLabel} ariaLabel={ariaLabel} /> : null;

if (props.template) {
const defaultOptions = {
Expand Down

0 comments on commit d8b4052

Please sign in to comment.