1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(a11y): add labels and roles [EE-6717] (#11181)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run

This commit is contained in:
Chaim Lev-Ari 2024-02-19 16:37:26 +02:00 committed by GitHub
parent 6c89d3c0c9
commit ce3a1b8ba5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 72 additions and 30 deletions

View file

@ -188,6 +188,7 @@ export function Datatable<D extends DefaultType>({
isLoading={isLoading}
onSortChange={handleSortChange}
data-cy={dataCy}
aria-label={`${title} table`}
/>
<DatatableFooter

View file

@ -11,6 +11,7 @@ interface Props<D extends DefaultType> extends AutomationTestingProps {
onSortChange?(colId: string, desc: boolean): void;
isLoading?: boolean;
emptyContentLabel?: string;
'aria-label'?: string;
}
export function DatatableContent<D extends DefaultType>({
@ -20,12 +21,13 @@ export function DatatableContent<D extends DefaultType>({
isLoading,
emptyContentLabel,
'data-cy': dataCy,
'aria-label': ariaLabel,
}: Props<D>) {
const headerGroups = tableInstance.getHeaderGroups();
const pageRowModel = tableInstance.getPaginationRowModel();
return (
<Table data-cy={dataCy} className="nowrap-cells">
<Table data-cy={dataCy} className="nowrap-cells" aria-label={ariaLabel}>
<thead>
{headerGroups.map((headerGroup) => (
<Table.HeaderRow<D>

View file

@ -28,6 +28,8 @@ interface Props<D extends DefaultType> {
* keyword to filter by
*/
search?: string;
'aria-label'?: string;
}
export function NestedDatatable<D extends DefaultType>({
@ -39,6 +41,7 @@ export function NestedDatatable<D extends DefaultType>({
isLoading,
initialSortBy,
search,
'aria-label': ariaLabel,
}: Props<D>) {
const tableInstance = useReactTable<D>({
columns,
@ -70,6 +73,7 @@ export function NestedDatatable<D extends DefaultType>({
isLoading={isLoading}
emptyContentLabel={emptyContentLabel}
renderRow={(row) => <Table.Row<D> cells={row.getVisibleCells()} />}
aria-label={ariaLabel}
/>
</Table.Container>
</NestedTable>

View file

@ -42,6 +42,7 @@ export function SearchBar({
onChange={(e) => setSearchValue(e.target.value)}
placeholder={placeholder}
data-cy={dataCy}
aria-label="Search input"
/>
{children}
<Button onClick={onClear} icon={X} color="none" disabled={!searchValue} />

View file

@ -1,5 +1,5 @@
import clsx from 'clsx';
import { PropsWithChildren } from 'react';
import { AriaAttributes, PropsWithChildren } from 'react';
import { AutomationTestingProps } from '@/types';
@ -14,23 +14,21 @@ import { TableHeaderCell } from './TableHeaderCell';
import { TableHeaderRow } from './TableHeaderRow';
import { TableRow } from './TableRow';
interface Props extends AutomationTestingProps {
interface Props extends AutomationTestingProps, AriaAttributes {
className?: string;
}
function MainComponent({
children,
className,
'data-cy': dataCy,
...props
}: PropsWithChildren<Props>) {
return (
<div className="table-responsive">
<table
data-cy={dataCy}
className={clsx(
'table-hover table-filters nowrap-cells table',
className
)}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
className={clsx('table-hover table-filters table', className)}
>
{children}
</table>

View file

@ -23,7 +23,7 @@ export function TableTitle({
<>
<div className={clsx('toolBar flex-col', className)} id={id}>
<div className="flex w-full items-center gap-1 p-0">
<div className="toolBarTitle">
<h2 className="toolBarTitle m-0 text-2xl">
{icon && (
<div className="widget-icon">
<Icon icon={icon} className="space-right" />
@ -31,7 +31,7 @@ export function TableTitle({
)}
{label}
</div>
</h2>
{children}
</div>
</div>

View file

@ -17,6 +17,7 @@ export function buildExpandColumn<T extends DefaultType>(): ColumnDef<T> {
onClick={table.getToggleAllRowsExpandedHandler()}
color="none"
icon={table.getIsAllRowsExpanded() ? ChevronDown : ChevronUp}
title="Expand all"
/>
)
);
@ -32,6 +33,7 @@ export function buildExpandColumn<T extends DefaultType>(): ColumnDef<T> {
}}
color="none"
icon={row.getIsExpanded() ? ChevronDown : ChevronUp}
title={row.getIsExpanded() ? 'Collapse' : 'Expand'}
/>
),
enableColumnFilter: false,