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.
65 lines
2.4 KiB
Vue
65 lines
2.4 KiB
Vue
<script setup lang="ts">
|
||
import { computed } from "vue";
|
||
|
||
import { TableCell, TableRow } from "@/components/ui/table";
|
||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||
import { Timestamp } from "@/components/ui/timestamp";
|
||
import { useOrgStore } from "@/stores/org";
|
||
import { activityDetail } from "./activity-detail";
|
||
import { describeTimelineEvent } from "@/tasks/timeline-event";
|
||
import { useTasksStore, type ActivityEvent } from "@/stores/tasks";
|
||
|
||
const identities = useOrgStore();
|
||
identities.watchIdentities();
|
||
|
||
/**
|
||
* One row of the live activity table. A row whose event resolves to a task is
|
||
* a link to it, and has to behave like one for a keyboard: Enter and Space both
|
||
* open it, which is why it is focusable and carries role="link".
|
||
*/
|
||
const props = defineProps<{ event: ActivityEvent }>();
|
||
const emit = defineEmits<{ open: [taskID: number] }>();
|
||
|
||
const tasks = useTasksStore();
|
||
const taskID = computed(() => tasks.taskIDFor(props.event));
|
||
// The detail is cut to one line by activityDetail and clamped again in the
|
||
// cell so a long unbroken token (a path, a URL, a hash) cannot widen the column
|
||
// past the table.
|
||
const detail = computed(() => activityDetail(props.event, identities.identityName));
|
||
|
||
function open() {
|
||
if (taskID.value > 0) emit("open", taskID.value);
|
||
}
|
||
|
||
</script>
|
||
|
||
<template>
|
||
<TableRow
|
||
:class="taskID > 0 ? 'cursor-pointer' : ''"
|
||
@click="open"
|
||
>
|
||
<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>
|
||
<TableCell class="w-[55%] max-w-0">
|
||
<Tooltip>
|
||
<TooltipTrigger as-child>
|
||
<span tabindex="0" class="block truncate">{{ detail.text }}</span>
|
||
</TooltipTrigger>
|
||
<TooltipContent v-if="detail.truncated">{{ detail.full }}</TooltipContent>
|
||
</Tooltip>
|
||
</TableCell>
|
||
<TableCell><Timestamp :at="event.at" /></TableCell>
|
||
</TableRow>
|
||
</template>
|