Skip to content

Commit

Permalink
a11y: UILD-455: Improve WCAG 2.1 AA compliance for Authority lookup c…
Browse files Browse the repository at this point in the history
…omponent (#56)
  • Loading branch information
s3fs authored Dec 16, 2024
1 parent a4c7a4c commit 0911aaf
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/common/styles/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $blue-700: #255096;
$blue-600: #2d62b7;
$blue-800: #1d3f75;
$gray-200: #d7d8da;
$gray-400: #8d9095;
$gray-400: #727272;
$gray-600: #3d3f42;
$blue-100: #d8e3f5;
$blue-400: #6591d9;
Expand Down
6 changes: 5 additions & 1 deletion src/components/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ type ButtonGroupProps = {
};

export const ButtonGroup = ({ className, fullWidth, children }: ButtonGroupProps) => {
return <div className={classNames('button-group', { 'full-width': fullWidth }, className)}>{children}</div>;
return (
<div role="tablist" className={classNames('button-group', { 'full-width': fullWidth }, className)}>
{children}
</div>
);
};
4 changes: 3 additions & 1 deletion src/components/ComplexLookupField/ComplexLookupField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC } from 'react';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, useIntl } from 'react-intl';
import classNames from 'classnames';
import { IS_EMBEDDED_MODE } from '@common/constants/build.constants';
import { VALUE_DIVIDER } from '@common/constants/complexLookup.constants';
Expand All @@ -20,6 +20,7 @@ interface Props {
}

export const ComplexLookupField: FC<Props> = ({ value = undefined, id, entry, onChange }) => {
const { formatMessage } = useIntl();
const { layout, htmlId } = entry;
const lookupConfig = COMPLEX_LOOKUPS_CONFIG[layout?.api as string];
const buttonConfigLabel = lookupConfig?.labels?.button;
Expand Down Expand Up @@ -54,6 +55,7 @@ export const ComplexLookupField: FC<Props> = ({ value = undefined, id, entry, on
onClick={() => handleDelete(id)}
className="complex-lookup-selected-delete"
data-testid="complex-lookup-selected-delete"
aria-label={formatMessage({ id: 'ld.aria.edit.removeComplexLookupFieldValue' })}
>
<CloseIcon />
</button>
Expand Down
10 changes: 8 additions & 2 deletions src/components/ComplexLookupField/MarcPreviewComplexLookup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export const MarcPreviewComplexLookup: FC<MarcPreviewComplexLookupProps> = ({ on
const { complexValue: marcPreviewData, metadata: marcPreviewMetadata } = useMarcPreviewState();

const renderCloseButton = () => (
<Button data-testid="nav-close-button" type={ButtonType.Icon} onClick={onClose} className="nav-close">
<Button
ariaLabel={formatMessage({ id: 'ld.aria.complexLookup.marcPreview.close' })}
data-testid="nav-close-button"
type={ButtonType.Icon}
onClick={onClose}
className="nav-close"
>
<Times16 />
</Button>
);
Expand Down Expand Up @@ -60,7 +66,7 @@ export const MarcPreviewComplexLookup: FC<MarcPreviewComplexLookupProps> = ({ on
</Button>
</div>
</SearchControlPane>
<div className="marc-preview-content">
<div className="marc-preview-content" tabIndex={0}>
<div className="marc-preview-content-title">
<FormattedMessage id="ld.marcAuthorityRecord" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/DropdownField/DropdownField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const DropdownField: FC<IDropdownField> = ({
disabled={isDisabled}
className="edit-section-field-input dropdown-field"
data-testid={testId}
ariaLabelledby={htmlId}
ariaLabelledBy={htmlId}
/>
);
};
7 changes: 4 additions & 3 deletions src/components/Table/TableFlex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export const TableFlex = ({ header, data, className, onRowClick, onHeaderCellCli
};

return (
<div data-testid="table" className={classNames(table, tableFlex, className)}>
<div ref={tableHeadElemRef} className={tableHead}>
<div ref={tableHeadRowElemRef} className={tableRow}>
<div role="table" data-testid="table" className={classNames(table, tableFlex, className)}>
<div role="rowgroup" ref={tableHeadElemRef} className={tableHead}>
<div role="row" ref={tableHeadRowElemRef} className={tableRow}>
{sortedHeaderEntries.map(([key, { label, className, ...rest }]) => (
<div
key={key}
Expand Down Expand Up @@ -105,6 +105,7 @@ export const TableFlex = ({ header, data, className, onRowClick, onHeaderCellCli
className={classNames('table-cell', className, headerClassName)}
data-testid={key}
key={key}
role="cell"
{...rest}
>
<div className="table-cell-content">{(children || label) ?? ''}</div>
Expand Down
2 changes: 2 additions & 0 deletions translations/ui-linked-data/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"ld.searchQueryWouldBeHere": "{query} would be here",
"ld.continue": "Continue",
"ld.aria.modal.close": "Close {modalKind} modal",
"ld.aria.complexLookup.marcPreview.close": "Close lookup MARC preview section",
"ld.aria.advancedSearch.queryInput": "Advanced search row query input",
"ld.aria.advancedSearch.operator": "Advanced search row operator",
"ld.aria.advancedSearch.qualifier": "Advanced search row qualifier",
Expand All @@ -197,6 +198,7 @@
"ld.aria.edit.close": "Close edit page",
"ld.aria.edit.deleteComponent": "Delete component",
"ld.aria.edit.duplicateComponent": "Duplicate component",
"ld.aria.edit.removeComplexLookupFieldValue": "Remove complex lookup field value",
"ld.aria.resourcePreview.close": "Close resource preview pane",
"ld.aria.externalResourcePreview.close": "Close external resource preview page",
"ld.aria.marcAuthorityPreview.close": "Close MARC authority preview",
Expand Down

0 comments on commit 0911aaf

Please sign in to comment.