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

storage: Improve table accessibility #20471

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pkg/storaged/pages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -608,19 +608,19 @@ export const PageTable = ({ emptyCaption, aria_label, pages, crossrefs, sorted,
</Card>);
} else {
const cols = [
<Td key="1" onClick={onClick}>
<Th scope="row" key="1" onClick={onClick}>
Copy link
Member

Choose a reason for hiding this comment

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

This would be correct from the HTML side of things. I haven't looked to see if there are any stylistic implications (if it changes the look) yet, but I'll do that in a little bit.

Good catch on seeing that scope is deprecated for <td>! I felt it was just for <th> at first, but saw it used and mentioned for <td>, but I guess I saw old docs and skipped that part of the documentation on MDN. Thanks for finding and mentioning it!

<div className="indent" style={ { "--level": level } }>
<Truncate content={name} />
{info}
</div>
</Td>,
</Th>,
<Td key="2" onClick={onClick} modifier="nowrap">{type}</Td>,
<Td key="3" onClick={onClick} modifier="nowrap">{location}</Td>,
<Td key="4" onClick={onClick} className="storage-size-column">{size}</Td>,
<Td key="5" className="pf-v5-c-table__action">{actions || <div /> }</Td>,
];
if (show_icons)
cols.unshift(<Td key="0" onClick={onClick} className="storage-device-icon">{icon}</Td>);
cols.unshift(<Td key="0" onClick={onClick} className="storage-device-icon" aria-hidden="true">{icon}</Td>);

rows.push(
<Tr key={key}
Expand Down Expand Up @@ -710,12 +710,12 @@ export const PageTable = ({ emptyCaption, aria_label, pages, crossrefs, sorted,
{ pages &&
<Thead>
<Tr>
{ show_icons && <Th aria-label={_("Category")} />}
<Th>{_("ID")}</Th>
<Th>{_("Type")}</Th>
<Th>{_("Location")}</Th>
<Th className="storage-size-column-header">{_("Size")}</Th>
<Th aria-label={_("Actions")} />
{ show_icons && <Td aria-hidden="true" /> }
Copy link
Member

Choose a reason for hiding this comment

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

As far as I can tell, this is not a "hack" but completely valid.

I looked at docs for thead, tr, td, th. It seems there's nothing stopping anyone from putting either a td or th inside of a parent element of tr, even if the parent of that tr is a thead or tbody (or in some cases, even just table, if there is no caption, thead, and tbody).

Copy link
Member Author

@mvollmer mvollmer May 16, 2024

Choose a reason for hiding this comment

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

As far as I can tell, this is not a "hack" but completely valid.

I was just reading this: patternfly/patternfly#6272

Accessibility rules have changed, <td>s in theads are no longer acceptable.

shrug

<Th scope="col">{_("ID")}</Th>
<Th scope="col">{_("Type")}</Th>
<Th scope="col">{_("Location")}</Th>
<Th scope="col" className="storage-size-column-header">{_("Size")}</Th>
<Th scope="col" aria-label={_("Actions")} />
</Tr>
</Thead>
}
Expand Down