Merge pull request #9931 from overleaf/ii-dashboard-table-accessibility

[web] Project dashboard table accessibility improvements

GitOrigin-RevId: ac8202b587c796ad1560e26242c1edca8c72a897
This commit is contained in:
Alf Eaton 2022-10-14 11:00:00 +01:00 committed by Copybot
parent b471b0b96e
commit 6c83939765
5 changed files with 22 additions and 18 deletions

View file

@ -114,6 +114,7 @@
"created_at": "", "created_at": "",
"creating": "", "creating": "",
"current_password": "", "current_password": "",
"date_and_owner": "",
"date": "", "date": "",
"delete": "", "delete": "",
"delete_account": "", "delete_account": "",
@ -486,6 +487,7 @@
"project_too_much_editable_text": "", "project_too_much_editable_text": "",
"project_url": "", "project_url": "",
"projects": "", "projects": "",
"projects_list": "",
"public": "", "public": "",
"pull_github_changes_into_sharelatex": "", "pull_github_changes_into_sharelatex": "",
"push_sharelatex_changes_to_github": "", "push_sharelatex_changes_to_github": "",

View file

@ -36,11 +36,9 @@ export default function ProjectListTableRow({
onChange={handleCheckboxChange} onChange={handleCheckboxChange}
data-project-id={project.id} data-project-id={project.id}
/> />
<label <label htmlFor={`select-project-${project.id}`} className="sr-only">
htmlFor={`select-project-${project.id}`} {t('select_project', { project: project.name })}
aria-label={t('select_project', { project: project.name })} </label>
className="sr-only"
/>
</td> </td>
<td className="dash-cell-name"> <td className="dash-cell-name">
<a href={`/project/${project.id}`}>{project.name}</a>{' '} <a href={`/project/${project.id}`}>{project.name}</a>{' '}

View file

@ -12,10 +12,10 @@ function SortBtn({ onClick, text, iconType, screenReaderText }: SortBtnProps) {
<button <button
className="btn-link table-header-sort-btn hidden-xs" className="btn-link table-header-sort-btn hidden-xs"
onClick={onClick} onClick={onClick}
aria-label={screenReaderText}
> >
{text} {text}
{iconType ? <Icon className="tablesort" type={iconType} /> : null} {iconType ? <Icon className="tablesort" type={iconType} /> : null}
<span className="sr-only">{screenReaderText}</span>
</button> </button>
) )
} }
@ -41,6 +41,7 @@ function ProjectListTable() {
return ( return (
<table className="project-dash-table"> <table className="project-dash-table">
<caption className="sr-only">{t('projects_list')}</caption>
<thead className="sr-only-xs"> <thead className="sr-only-xs">
<tr> <tr>
<th <th
@ -57,11 +58,9 @@ function ProjectListTable() {
} }
disabled={visibleProjects.length === 0} disabled={visibleProjects.length === 0}
/> />
<label <label htmlFor="project-list-table-select-all" className="sr-only">
htmlFor="project-list-table-select-all" {t('select_all_projects')}
aria-label={t('select_all_projects')} </label>
className="sr-only"
/>
</th> </th>
<th <th
className="dash-cell-name" className="dash-cell-name"
@ -83,9 +82,9 @@ function ProjectListTable() {
</th> </th>
<th <th
className="dash-cell-date-owner visible-xs" className="dash-cell-date-owner visible-xs"
aria-label={`${t('date')}${t('owner')}`} aria-label={t('date_and_owner')}
> >
{`${t('date')}${t('owner')}`} {t('date_and_owner')}
</th> </th>
<th <th
className="dash-cell-owner hidden-xs" className="dash-cell-owner hidden-xs"
@ -126,7 +125,9 @@ function ProjectListTable() {
<th className="dash-cell-tag visible-xs" aria-label={t('tags')}> <th className="dash-cell-tag visible-xs" aria-label={t('tags')}>
{t('tags')} {t('tags')}
</th> </th>
<th className="dash-cell-actions">{t('actions')}</th> <th className="dash-cell-actions" aria-label={t('actions')}>
{t('actions')}
</th>
</tr> </tr>
</thead> </thead>

View file

@ -964,6 +964,7 @@
"make_copy": "Make a copy", "make_copy": "Make a copy",
"restore": "Restore", "restore": "Restore",
"title": "Title", "title": "Title",
"date_and_owner": "Date and owner",
"last_modified": "Last Modified", "last_modified": "Last Modified",
"last_updated": "Last Updated", "last_updated": "Last Updated",
"no_projects": "No projects", "no_projects": "No projects",
@ -1498,6 +1499,7 @@
"download": "Download", "download": "Download",
"email": "Email", "email": "Email",
"owner": "Owner", "owner": "Owner",
"date": "Date",
"read_and_write": "Read and Write", "read_and_write": "Read and Write",
"read_only": "Read Only", "read_only": "Read Only",
"publish": "Publish", "publish": "Publish",
@ -1909,5 +1911,6 @@
"show_x_more": "Show __x__ more", "show_x_more": "Show __x__ more",
"show_x_more_projects": "Show __x__ more projects", "show_x_more_projects": "Show __x__ more projects",
"showing_x_out_of_n_projects": "Showing __x__ out of __n__ projects.", "showing_x_out_of_n_projects": "Showing __x__ out of __n__ projects.",
"make_a_copy": "Make a copy" "make_a_copy": "Make a copy",
"projects_list": "Projects list"
} }

View file

@ -58,9 +58,9 @@ describe('<ProjectListTable />', function () {
it('renders buttons for sorting all sortable columns', function () { it('renders buttons for sorting all sortable columns', function () {
renderWithProjectListContext(<ProjectListTable />) renderWithProjectListContext(<ProjectListTable />)
screen.getByText('Sort by Title') screen.getByRole('button', { name: 'Sort by Title' })
screen.getByText('Sort by Owner') screen.getByRole('button', { name: 'Sort by Owner' })
screen.getByText('Reverse Last Modified sort order') // currently sorted screen.getByRole('button', { name: 'Reverse Last Modified sort order' }) // currently sorted
}) })
it('renders project title, owner, last modified, and action buttons', async function () { it('renders project title, owner, last modified, and action buttons', async function () {