fix(ui): rows keep table semantics; first-cell link/button is the focus target (#1750)
DataTable, ActivityRow, LiveActivityCard's group row and CaptureRow no longer put role=link/button, tabindex or aria-label on the <tr>. The row keeps its mouse click handler; the first cell carries a real RouterLink (DataTable rowLink) or button with the accessible name, so keyboard and screen-reader users get a focus target and rows keep row/cell semantics. The live-activity group row's disclosure button and open button are now siblings, not nested.
This commit is contained in:
4 files changed
+68
-58
No files matched your search
@@ -40,18 +40,18 @@ function open(): void {
|
||||
<template>
|
||||
<TableRow
|
||||
:data-state="isSelected ? 'selected' : undefined"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:aria-current="isSelected ? 'true' : undefined"
|
||||
:aria-label="label"
|
||||
class="cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
||||
class="cursor-pointer"
|
||||
@click="open"
|
||||
@keydown.enter.prevent="open"
|
||||
@keydown.space.prevent="open"
|
||||
>
|
||||
<TableCell class="font-mono">{{
|
||||
props.capture.source || "(unknown)"
|
||||
}}</TableCell>
|
||||
<TableCell class="font-mono">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-sm focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
||||
:aria-label="label"
|
||||
:aria-current="isSelected ? 'true' : undefined"
|
||||
@click.stop="open"
|
||||
>{{ props.capture.source || "(unknown)" }}</button>
|
||||
</TableCell>
|
||||
<TableCell><Timestamp :at="props.capture.received_at" /></TableCell>
|
||||
<!-- An unidentified capture is never dispatched. -->
|
||||
<TableCell>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts" generic="Row">
|
||||
import { computed, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { RouterLink, useRouter } from "vue-router";
|
||||
import { useLocalStorage } from "@vueuse/core";
|
||||
import { ArrowDown, ArrowUp, ArrowUpDown, Columns3 } from "@lucide/vue";
|
||||
|
||||
@@ -130,17 +130,23 @@ function open(row: Row): void {
|
||||
<template v-for="row in sorted" :key="rowKey(row)">
|
||||
<TableRow
|
||||
:data-row-key="rowKey(row)"
|
||||
:tabindex="rowLink || expandable ? 0 : undefined"
|
||||
:role="rowLink ? 'link' : undefined"
|
||||
:aria-label="rowLink && rowLabel ? rowLabel(row) : undefined"
|
||||
:tabindex="expandable ? 0 : undefined"
|
||||
:aria-expanded="expandable ? expanded.has(rowKey(row)) : undefined"
|
||||
:class="['align-top', (rowLink || expandable) && 'cursor-pointer', rowClass?.(row)]"
|
||||
@click="open(row)"
|
||||
@keydown.enter.self.prevent="open(row)"
|
||||
@keydown.space.self.prevent="open(row)"
|
||||
>
|
||||
<TableCell v-for="column in shown" :key="column.id" :class="column.class">
|
||||
<slot :name="`cell-${column.id}`" :row="row" />
|
||||
<TableCell v-for="(column, cellIndex) in shown" :key="column.id" :class="column.class">
|
||||
<RouterLink
|
||||
v-if="cellIndex === 0 && rowLink"
|
||||
:to="rowLink(row)"
|
||||
:aria-label="rowLabel ? rowLabel(row) : undefined"
|
||||
class="rounded-sm focus-visible:outline-2 focus-visible:outline-ring"
|
||||
@click.stop
|
||||
><slot :name="`cell-${column.id}`" :row="row"
|
||||
/></RouterLink>
|
||||
<slot v-else :name="`cell-${column.id}`" :row="row" />
|
||||
</TableCell>
|
||||
<TableCell v-if="trailing"><slot name="actions" :row="row" /></TableCell>
|
||||
</TableRow>
|
||||
|
||||
@@ -36,16 +36,18 @@ function open() {
|
||||
<template>
|
||||
<TableRow
|
||||
:class="taskID > 0 ? 'cursor-pointer' : ''"
|
||||
:role="taskID > 0 ? 'link' : undefined"
|
||||
:tabindex="taskID > 0 ? 0 : undefined"
|
||||
:title="taskID > 0 ? 'Open task details' : undefined"
|
||||
@click="open"
|
||||
@keydown.enter.prevent="open"
|
||||
@keydown.space.prevent="open"
|
||||
>
|
||||
<TableCell class="font-medium">{{
|
||||
describeTimelineEvent({ ...props.event, at: undefined, detail: undefined }).title
|
||||
}}</TableCell>
|
||||
<TableCell class="font-medium">
|
||||
<button
|
||||
v-if="taskID > 0"
|
||||
type="button"
|
||||
class="rounded-sm text-left focus-visible:outline-2 focus-visible:outline-ring"
|
||||
aria-label="Open task details"
|
||||
@click.stop="open"
|
||||
>{{ describeTimelineEvent({ ...props.event, at: undefined, detail: undefined }).title }}</button>
|
||||
<template v-else>{{ describeTimelineEvent({ ...props.event, at: undefined, detail: undefined }).title }}</template>
|
||||
</TableCell>
|
||||
<TableCell class="font-mono">{{
|
||||
taskID > 0 ? `#${taskID}` : "–"
|
||||
}}</TableCell>
|
||||
|
||||
@@ -163,46 +163,48 @@ function openTask(taskID: number) {
|
||||
/>
|
||||
<template v-else>
|
||||
<!--
|
||||
The group row keeps ActivityRow's link contract: when its
|
||||
events resolve to a task, the row itself opens the task,
|
||||
with the same focusable role="link" behaviour. The
|
||||
disclosure button is a stop-propagated control inside the
|
||||
first cell, so it never fights the row-level link.
|
||||
The row stays a row: mouse clicks open the task via the
|
||||
row handler, and the first cell holds the two real focus
|
||||
targets -- the disclosure button and, when the group
|
||||
resolves to a task, an open button carrying its title.
|
||||
-->
|
||||
<TableRow
|
||||
:class="group.taskID > 0 ? 'cursor-pointer' : ''"
|
||||
:role="group.taskID > 0 ? 'link' : undefined"
|
||||
:tabindex="group.taskID > 0 ? 0 : undefined"
|
||||
:title="
|
||||
group.taskID > 0 ? 'Open task details' : undefined
|
||||
"
|
||||
@click="group.taskID > 0 && openTask(group.taskID)"
|
||||
@keydown.enter.prevent="
|
||||
group.taskID > 0 && openTask(group.taskID)
|
||||
"
|
||||
@keydown.space.prevent="
|
||||
group.taskID > 0 && openTask(group.taskID)
|
||||
"
|
||||
>
|
||||
<TableCell class="font-medium">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded hover:opacity-80"
|
||||
:aria-expanded="isOpen(group)"
|
||||
:aria-label="`${isOpen(group) ? 'Hide' : 'Show'} ${group.count} ${group.label} events`"
|
||||
@click.stop="toggle(group.key)"
|
||||
>
|
||||
<ChevronDown
|
||||
v-if="isOpen(group)"
|
||||
class="size-3.5 shrink-0 text-fg-subtle"
|
||||
/>
|
||||
<ChevronRight
|
||||
v-else
|
||||
class="size-3.5 shrink-0 text-fg-subtle"
|
||||
/>
|
||||
{{ describeTimelineEvent({ ...group.representative, at: undefined, detail: undefined }).title }}
|
||||
<Badge variant="idle">×{{ group.count }}</Badge>
|
||||
</button>
|
||||
<div class="flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded hover:opacity-80 focus-visible:outline-2 focus-visible:outline-ring"
|
||||
:aria-expanded="isOpen(group)"
|
||||
:aria-label="`${isOpen(group) ? 'Hide' : 'Show'} ${group.count} ${group.label} events`"
|
||||
@click.stop="toggle(group.key)"
|
||||
>
|
||||
<ChevronDown
|
||||
v-if="isOpen(group)"
|
||||
class="size-3.5 shrink-0 text-fg-subtle"
|
||||
/>
|
||||
<ChevronRight
|
||||
v-else
|
||||
class="size-3.5 shrink-0 text-fg-subtle"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
v-if="group.taskID > 0"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded hover:opacity-80 focus-visible:outline-2 focus-visible:outline-ring"
|
||||
aria-label="Open task details"
|
||||
@click.stop="openTask(group.taskID)"
|
||||
>
|
||||
{{ describeTimelineEvent({ ...group.representative, at: undefined, detail: undefined }).title }}
|
||||
<Badge variant="idle">×{{ group.count }}</Badge>
|
||||
</button>
|
||||
<template v-else>
|
||||
{{ describeTimelineEvent({ ...group.representative, at: undefined, detail: undefined }).title }}
|
||||
<Badge variant="idle">×{{ group.count }}</Badge>
|
||||
</template>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell class="font-mono">{{
|
||||
group.taskID > 0 ? `#${group.taskID}` : "–"
|
||||
|
||||
Reference in new issue
Block a user