Skip to content

Commit

Permalink
fix: render a11y stuff in a div outside of the <table/> (#2515)
Browse files Browse the repository at this point in the history
Co-authored-by: Matvey Kukuy <[email protected]>
  • Loading branch information
Kiryous and Matvey-Kuk authored Nov 18, 2024
1 parent d0ed6c9 commit f3f38ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion keep-ui/app/alerts/alert-table-headers.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// culled from https://github.com/cpvalente/ontime/blob/master/apps/client/src/features/cuesheet/cuesheet-table-elements/CuesheetHeader.tsx

import { CSSProperties, ReactNode } from "react";
import { CSSProperties, ReactNode, RefObject } from "react";
import {
closestCenter,
DndContext,
Expand Down Expand Up @@ -137,12 +137,14 @@ interface Props {
columns: ColumnDef<AlertDto>[];
table: Table<AlertDto>;
presetName: string;
a11yContainerRef: RefObject<HTMLDivElement>;
}

export default function AlertsTableHeaders({
columns,
table,
presetName,
a11yContainerRef,
}: Props) {
const [columnOrder, setColumnOrder] = useLocalStorage<ColumnOrderState>(
`column-order-${presetName}`,
Expand Down Expand Up @@ -191,6 +193,9 @@ export default function AlertsTableHeaders({
sensors={sensors}
collisionDetection={closestCenter}
onDragEnd={onDragEnd}
accessibility={{
container: a11yContainerRef.current ?? undefined,
}}
>
<TableRow key={headerGroup.id}>
<SortableContext
Expand Down
6 changes: 5 additions & 1 deletion keep-ui/app/alerts/alert-table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useRef, useState } from "react";
import { Table, Callout, Card } from "@tremor/react";
import { AlertsTableBody } from "./alerts-table-body";
import { AlertDto } from "./models";
Expand Down Expand Up @@ -71,6 +71,8 @@ export function AlertTable({
setDismissedModalAlert,
mutateAlerts,
}: Props) {
const a11yContainerRef = useRef<HTMLDivElement>(null);

const [theme, setTheme] = useLocalStorage(
"alert-table-theme",
Object.values(severityMapping).reduce<{ [key: string]: string }>(
Expand Down Expand Up @@ -326,11 +328,13 @@ export function AlertTable({
setSelectedTab={setSelectedTab}
/>
)}
<div ref={a11yContainerRef} className="sr-only" />
<Table className="[&>table]:table-fixed [&>table]:w-full">
<AlertsTableHeaders
columns={columns}
table={table}
presetName={presetName}
a11yContainerRef={a11yContainerRef}
/>
<AlertsTableBody
table={table}
Expand Down

0 comments on commit f3f38ff

Please sign in to comment.