-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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}> | ||
<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} | ||
|
@@ -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" /> } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I was just reading this: patternfly/patternfly#6272
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> | ||
} | ||
|
There was a problem hiding this comment.
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!