Make alert metric edit cells keyboard-accessible

Each metric value cell on /alerts/thresholds is a clickable surface that
opens an inline editor for the threshold value. The wrapper was a plain
<div> with cursor-pointer and onClick — focusable for mouse but not for
keyboard, and screen readers didn't announce it as a button.

Add role="button", tabIndex={0}, onKeyDown for Enter/Space activation,
and an aria-label that mirrors the existing title hint. The mouse path
is unchanged; keyboard users can now Tab into the cells and press Enter
to open the editor.
This commit is contained in:
rcourtman
2026-05-09 22:03:42 +01:00
parent d8f6b1e508
commit de6deb0f86
@@ -352,7 +352,7 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
);
}
const openMetricEditor = (e: MouseEvent) => {
const openMetricEditor = (e?: MouseEvent) => {
startEditing(metric, e);
};
@@ -366,9 +366,18 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
when={isEditing()}
fallback={
<div
role="button"
tabIndex={0}
onClick={openMetricEditor}
onKeyDown={(event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
openMetricEditor();
}
}}
class="cursor-pointer hover:bg-surface-hover rounded px-1 py-0.5 transition-colors"
title={getAlertResourceTableEditMetricTitle()}
aria-label={getAlertResourceTableEditMetricTitle()}
>
<MetricValueWithHeat
resourceId={props.resource.id}