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

pkg/lib: Give empty "Th" elements a aria-label attribute #20358

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions pkg/lib/cockpit-components-table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
*/

import cockpit from 'cockpit';

import React, { useState, useEffect } from 'react';
import {
ExpandableRowContent,
Expand All @@ -28,6 +30,8 @@ import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/esm

import './cockpit-components-table.scss';

const _ = cockpit.gettext;

/* This is a wrapper around PF Table component
* See https://www.patternfly.org/components/table/
* Properties (all optional unless specified otherwise):
Expand Down Expand Up @@ -259,9 +263,13 @@ export const ListingTable = ({
<Table {...extraProps} {...tableProps}>
{showHeader && <Thead>
<Tr>
{isExpandable && <Th />}
{!onHeaderSelect && onSelect && <Th />}
{onHeaderSelect && onSelect && <Th select={{
{/* HACK - https://github.com/patternfly/patternfly/issues/6643
We should probably be using screenReaderText instead of aria-label
for the first two here, but that will change the table layout.
*/}
{isExpandable && <Th aria-label={_("Row expansion")} />}
{!onHeaderSelect && onSelect && <Th aria-label={_("Row select")} />}
{onHeaderSelect && onSelect && <Th aria-label={_("Row select")} select={{
Comment on lines +271 to +272
Copy link
Contributor

Choose a reason for hiding this comment

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

These 2 added lines are not executed by any test.

onSelect: onHeaderSelect,
isSelected: rows.every(r => r.selected)
}} />}
Expand Down