Harden tables selection interactions
This commit is contained in:
@@ -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};";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user