Skip to content

Commit

Permalink
patternfly: Give empty "Th" elements a aria-label attribute
Browse files Browse the repository at this point in the history
As requested by this warning:

    Th: Table headers must have an accessible name. If the Th is
    intended to be visually empty, pass in screenReaderText. If the Th
    contains only non-text, interactive content such as a checkbox or
    expand toggle, pass in an aria-label.

We can't use screenReaderText because of

    patternfly/patternfly#6643
  • Loading branch information
mvollmer committed May 21, 2024
1 parent 6e97b00 commit e7dd5bb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/networks/networkList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class NetworkList extends React.Component {
{ title: _("Connection"), props: { width: 15 } },
{ title: _("Forwarding mode"), props: { width: 15 } },
{ title: _("State"), props: { width: 20 } },
{ title: "", props: { width: 20 } },
{ title: "", props: { width: 20, "aria-label": _("Actions") } },
]}
emptyCaption={_("No network is defined on this host")}
rows={networks
Expand Down
2 changes: 1 addition & 1 deletion src/components/storagePools/storagePoolList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class StoragePoolList extends React.Component {
{ title: _("Size"), props: { width: 40 } },
{ title: _("Connection"), props: { width: 15 } },
{ title: _("State"), props: { width: 15 } },
{ title: "", props: { width: 15 } },
{ title: "", props: { width: 15, "aria-label": _("Actions") } },
]}
emptyCaption={_("No storage pool is defined on this host")}
rows={storagePools
Expand Down
2 changes: 1 addition & 1 deletion src/components/vm/disks/vmDisksCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export const VmDisksCard = ({ vm, vms, disks, renderCapacity, supportedDiskBusTy
if (renderAdditional)
columnTitles.push(_("Additional"));

columnTitles.push('');
columnTitles.push({ title: '', props: { "aria-label": _("Actions") } });
}

const rows = disks.map(disk => {
Expand Down
5 changes: 4 additions & 1 deletion src/components/vm/hostdevs/hostDevAdd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ const DevRow = ({ idPrefix, type, selectableDevices, setSelectableDevices }) =>
className="vm-device-table"
aria-label={_("Table of selectable host devices")}>
<Thead>
<Tr><Th />{[_("Product"), _("Vendor"), _("Location")].map(col => <Th key={col}>{col}</Th>)}</Tr>
<Tr>
<Th aria-label={_("Row select")} />
{[_("Product"), _("Vendor"), _("Location")].map(col => <Th key={col}>{col}</Th>)}
</Tr>
</Thead>
<Tbody>
{selectableDevices.map((dev, rowIndex) => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/vm/nics/vmNicsCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export class VmNetworkTab extends React.Component {
},
{
name: "",
aria: _("Actions"),
value: (network, networkId) => {
const isUp = network.state === 'up';
const nicPersistent = !!vm.inactiveXML.interfaces.filter(iface => iface.mac == network.mac).length;
Expand Down Expand Up @@ -527,7 +528,7 @@ export class VmNetworkTab extends React.Component {
let networkId = 1;
detailMap = detailMap.filter(d => !d.hidden);

const columnTitles = detailMap.map(target => target.name);
const columnTitles = detailMap.map(target => ({ title: target.name, props: { "aria-label": target.aria } }));
const sortIfaces = (a, b) => {
if (a.type !== b.type)
return a.type > b.type ? 1 : -1;
Expand Down
6 changes: 5 additions & 1 deletion src/components/vm/snapshots/vmSnapshotsCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class VmSnapshotsCard extends React.Component {
},
{
name: "",
aria: _("Actions"),
value: (snap, snapId) => {
const revertSnapshotHelper = () => {
const revertDialogProps = {
Expand Down Expand Up @@ -210,7 +211,10 @@ export class VmSnapshotsCard extends React.Component {

detailMap = detailMap.filter(d => !d.hidden);

const columnTitles = detailMap.map(target => ({ title: target.name, props: { width: 15 } }));
const columnTitles = detailMap.map(target => ({
title: target.name,
props: { width: 15, "aria-label": target.aria }
}));
let rows = [];
if (vm.snapshots) {
rows = vm.snapshots.sort((a, b) => ((b.creationTime - a.creationTime) || (a.name.localeCompare(b.name)))).map((target, snapId) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/vms/hostvmslist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const HostVmsList = ({ vms, config, ui, storagePools, actions, networks, onAddEr
{ title: _("Name"), header: true, props: { width: 25 } },
{ title: _("Connection"), props: { width: 25 } },
{ title: _("State"), props: { width: 25 } },
{ title: "", props: { width: 25 } },
{ title: "", props: { width: 25, "aria-label": _("Actions") } },
]}
emptyCaption={_("No VM is running or defined on this host")}
rows={ combinedVmsFiltered
Expand Down

0 comments on commit e7dd5bb

Please sign in to comment.