Harden tables selection interactions

This commit is contained in:
2026-03-21 15:20:05 +01:00
parent fb6e5a4e86
commit 7a0ce00429
4 changed files with 69 additions and 4 deletions

View File

@@ -33,7 +33,13 @@
@if (MatchesModeFilter(cell))
{
<div class="@GetCellCssClass(cell, displayColumn.GroupKey)" @onclick="() => SelectCell(cell)">
<div
class="@GetCellCssClass(cell, displayColumn.GroupKey)"
role="button"
tabindex="0"
aria-pressed="@isSelectedCell"
@onclick="() => SelectCell(cell)"
@onkeydown="args => HandleCellKeyDown(args, cell)">
<div class="critical-table-cell-shell">
<div class="critical-table-cell-actions">
@if (string.Equals(CurrentMode, TablesReferenceMode.Reference, StringComparison.Ordinal))
@@ -306,5 +312,17 @@
private bool IsSelectedCell(CriticalTableCellDetail cell) =>
SelectedCell is not null && cell.ResultId == SelectedCell.ResultId;
private Task HandleCellKeyDown(KeyboardEventArgs args, CriticalTableCellDetail cell)
{
if (string.Equals(args.Key, "Enter", StringComparison.Ordinal) ||
string.Equals(args.Key, " ", StringComparison.Ordinal) ||
string.Equals(args.Key, "Spacebar", StringComparison.Ordinal))
{
return SelectCell(cell);
}
return Task.CompletedTask;
}
private static string BuildColumnSpanStyle(int span) => $"grid-column: span {span};";
}