Skip to content

Commit b837c63

Browse files
committed
Add proper table semantics & ARIA to view event list
1 parent 8545a02 commit b837c63

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/components/view/view-event-list.tsx

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ interface ViewEventListProps {
5959
onSelected: (event: CollectedEvent | undefined) => void;
6060
}
6161

62-
const ListContainer = styled.div`
62+
const ListContainer = styled.table`
63+
display: block;
6364
flex-grow: 1;
6465
position: relative;
6566
width: 100%;
@@ -79,7 +80,8 @@ const ListContainer = styled.div`
7980
}
8081
`;
8182

82-
const Column = styled.div`
83+
const Column = styled.td`
84+
display: block;
8385
overflow: hidden;
8486
text-overflow: ellipsis;
8587
white-space: nowrap;
@@ -134,7 +136,7 @@ const RowMarker = styled(Column)`
134136
border-left: 5px solid ${p => p.theme.containerBackground};
135137
`;
136138

137-
const MarkerHeader = styled.div`
139+
const MarkerHeader = styled.td`
138140
flex-basis: 10px;
139141
flex-shrink: 0;
140142
`;
@@ -221,7 +223,7 @@ const BuiltInApiRequestDetails = styled(Column)`
221223
flex-basis: 1000px;
222224
`;
223225

224-
const EventListRow = styled.div`
226+
const EventListRow = styled.tr`
225227
display: flex;
226228
flex-direction: row;
227229
align-items: center;
@@ -287,7 +289,7 @@ const TlsListRow = styled(EventListRow)`
287289
}
288290
`;
289291

290-
export const TableHeader = styled.header`
292+
export const TableHeaderRow = styled.tr`
291293
height: 38px;
292294
overflow: hidden;
293295
width: 100%;
@@ -306,7 +308,7 @@ export const TableHeader = styled.header`
306308
padding-right: 18px;
307309
box-sizing: border-box;
308310
309-
> div {
311+
> td {
310312
padding: 5px 0;
311313
margin-right: 10px;
312314
min-width: 0px;
@@ -397,7 +399,6 @@ const ExchangeRow = inject('uiStore')(observer(({
397399
} = exchange;
398400

399401
return <TrafficEventListRow
400-
role="row"
401402
aria-label={
402403
`${_.startCase(exchange.category)} ${
403404
request.method
@@ -424,7 +425,7 @@ const ExchangeRow = inject('uiStore')(observer(({
424425
className={isSelected ? 'selected' : ''}
425426
style={style}
426427
>
427-
<RowPin pinned={pinned}/>
428+
<RowPin aria-label={pinned ? 'Pinned' : undefined} pinned={pinned}/>
428429
<RowMarker category={category} title={describeEventCategory(category)} />
429430
<Method pinned={pinned}>{ request.method }</Method>
430431
<Status>
@@ -504,7 +505,6 @@ const RTCConnectionRow = observer(({
504505
const { category, pinned } = event;
505506

506507
return <TrafficEventListRow
507-
role="row"
508508
aria-label={
509509
`${
510510
event.closeState ? 'Closed' : 'Open'
@@ -558,7 +558,6 @@ const RTCStreamRow = observer(({
558558
const { category, pinned } = event;
559559

560560
return <TrafficEventListRow
561-
role="row"
562561
aria-label={
563562
`${
564563
event.closeState ? 'Closed' : 'Open'
@@ -659,7 +658,6 @@ const BuiltInApiRow = observer((p: {
659658
.join(', ');
660659

661660
return <TrafficEventListRow
662-
role="row"
663661
aria-label={
664662
`${_.startCase(category)} ${
665663
api.service.shortName
@@ -719,7 +717,6 @@ const TlsRow = observer((p: {
719717
const connectionTarget = tlsEvent.upstreamHostname || 'unknown domain';
720718

721719
return <TlsListRow
722-
role="row"
723720
aria-label={`${description} connection to ${connectionTarget}`}
724721
aria-rowindex={p.index + 1}
725722
data-event-id={tlsEvent.id}
@@ -761,7 +758,7 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
761758

762759
private KeyBoundListWindow = observer(
763760
React.forwardRef<HTMLDivElement>(
764-
(props: any, ref) => <section
761+
(props: any, ref) => <div
765762
{...props}
766763
style={Object.assign({}, props.style, { 'overflowY': 'scroll' })}
767764
ref={ref}
@@ -778,14 +775,14 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
778775
const { events, filteredEvents, isPaused } = this.props;
779776

780777
return <ListContainer>
781-
<TableHeader>
782-
<MarkerHeader />
783-
<Method>Method</Method>
784-
<Status>Status</Status>
785-
<Source>Source</Source>
786-
<Host>Host</Host>
787-
<PathAndQuery>Path and query</PathAndQuery>
788-
</TableHeader>
778+
<TableHeaderRow>
779+
<MarkerHeader role="columnheader" aria-label="Category" />
780+
<Method role="columnheader">Method</Method>
781+
<Status role="columnheader">Status</Status>
782+
<Source role="columnheader">Source</Source>
783+
<Host role="columnheader">Host</Host>
784+
<PathAndQuery role="columnheader">Path and query</PathAndQuery>
785+
</TableHeaderRow>
789786

790787
{
791788
events.length === 0

0 commit comments

Comments
 (0)