Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Accessibility): Fix accessibility for 'Show x entries' dropdown in tables #30818

Merged
merged 8 commits into from
Nov 18, 2024
23 changes: 13 additions & 10 deletions superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,36 @@ function SelectPageSize({
onChange,
}: SelectPageSizeRendererProps) {
return (
<span className="dt-select-page-size form-inline">
{t('page_size.show')}{' '}
<span
className="dt-select-page-size form-inline"
role="group"
aria-label={t('Select page size')}
>
<label htmlFor="pageSizeSelect" className="sr-only">
{t('Select page size')}
</label>
{t('Show')}{' '}
<select
id="pageSizeSelect"
className="form-control input-sm"
value={current}
onBlur={() => {}}
onChange={e => {
onChange(Number((e.target as HTMLSelectElement).value));
}}
aria-label={t('Show entries per page')}
Copy link
Member

@geido geido Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be enough to have just this aria-label here and set the number of entries here (while removing the aria-label from the individual options). Otherwise, the screen reader is reading "Show 10 entries per page, Show entries per page" which I think it is unnecessary. Also, on Firefox, when inspecting for accessibility I am getting this:

Screenshot 2024-11-13 at 16 09 29

I believe we need to have a label that labels the Select input. We can probably change the structure a bit so to keep the same layout but have the proper Label element and accessibility properties. What do you think?

>
{options.map(option => {
const [size, text] = Array.isArray(option)
? option
: [option, option];
const sizeLabel = size === 0 ? t('all') : size;
return (
<option
aria-label={t('Show %s entries', sizeLabel)}
key={size}
value={size}
>
<option key={size} value={size}>
{text}
</option>
);
})}
</select>{' '}
{t('page_size.entries')}
{t('entries per page')}
</span>
);
}
Expand Down
Loading