From 3b16dc511189efb0fdd1df3b243c7244a51f53a9 Mon Sep 17 00:00:00 2001 From: nikolai Date: Wed, 11 Dec 2024 11:32:26 +0500 Subject: [PATCH] a11y: UILD-453: Improve WCAG 2.1 AA compliance for Search page (#50) --- src/common/constants/uiElements.constants.ts | 5 +++++ .../AdvancedSearchModal/AdvancedSearchModal.tsx | 6 ++++++ src/components/FullDisplay/PreviewContent.tsx | 10 ++++++++-- src/components/Modal/Modal.tsx | 12 ++++++++++-- .../SearchResultEntry/SearchResultEntry.tsx | 11 +++++++++-- src/components/Select/Select.tsx | 6 +++--- src/components/WorkDetailsCard/WorkDetailsCard.tsx | 10 ++++++++-- translations/ui-linked-data/en.json | 10 ++++++++++ 8 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/common/constants/uiElements.constants.ts b/src/common/constants/uiElements.constants.ts index f5c6fb77..f36c595d 100644 --- a/src/common/constants/uiElements.constants.ts +++ b/src/common/constants/uiElements.constants.ts @@ -22,4 +22,9 @@ export enum DropdownItemType { customComponent = 'customComponent', } +export enum AriaModalKind { + Basic = 'Basic', + AdvancedSearch = 'Advanced search', +} + export const MAX_SEARCH_BAR_WIDTH = 30; diff --git a/src/components/AdvancedSearchModal/AdvancedSearchModal.tsx b/src/components/AdvancedSearchModal/AdvancedSearchModal.tsx index cf3ed735..ccf64153 100644 --- a/src/components/AdvancedSearchModal/AdvancedSearchModal.tsx +++ b/src/components/AdvancedSearchModal/AdvancedSearchModal.tsx @@ -13,6 +13,7 @@ import { import { formatRawQuery, generateSearchParamsState } from '@common/helpers/search.helper'; import { Select } from '@components/Select'; import state from '@state'; +import { AriaModalKind } from '@common/constants/uiElements.constants'; import './AdvancedSearchModal.scss'; enum AdvancedSearchInputs { @@ -70,6 +71,7 @@ export const AdvancedSearchModal: FC = memo(({ clearValues }) => { onCancel={closeModal} shouldCloseOnEsc submitButtonDisabled={submitButtonDisabled} + ariaModalKind={AriaModalKind.AdvancedSearch} >
{rawQuery.map(({ query, rowIndex, operator, qualifier, index }) => ( @@ -85,6 +87,7 @@ export const AdvancedSearchModal: FC = memo(({ clearValues }) => { options={SELECT_OPERATORS} className="cell-operator" onChange={({ value }) => onChangeInput(value, AdvancedSearchInputs.Operator, rowIndex)} + ariaLabel={formatMessage({ id: 'ld.aria.advancedSearch.operator' })} data-testid={`select-operators-${rowIndex}`} /> )} @@ -93,6 +96,7 @@ export const AdvancedSearchModal: FC = memo(({ clearValues }) => { data-testid={`text-input-${rowIndex}`} value={query ?? ''} onChange={({ target: { value } }) => onChangeInput(value, AdvancedSearchInputs.Query, rowIndex)} + ariaLabel={formatMessage({ id: 'ld.aria.advancedSearch.queryInput' })} /> +
), }, diff --git a/src/components/Select/Select.tsx b/src/components/Select/Select.tsx index 3236bd16..9db223e4 100644 --- a/src/components/Select/Select.tsx +++ b/src/components/Select/Select.tsx @@ -18,7 +18,7 @@ type Select = { withIntl?: boolean; className?: string; ariaLabel?: string; - ariaLabelledby?: string; + ariaLabelledBy?: string; [x: string]: any; }; @@ -30,7 +30,7 @@ export const Select: FC = ({ role="combobox" aria-expanded="false" aria-label={ariaLabel} - aria-labelledby={ariaLabelledby} + aria-labelledby={ariaLabelledBy} {...restProps} > {options.map(id => { diff --git a/src/components/WorkDetailsCard/WorkDetailsCard.tsx b/src/components/WorkDetailsCard/WorkDetailsCard.tsx index 57339ccb..cf9b695d 100644 --- a/src/components/WorkDetailsCard/WorkDetailsCard.tsx +++ b/src/components/WorkDetailsCard/WorkDetailsCard.tsx @@ -1,7 +1,7 @@ import { FC } from 'react'; import { Link } from 'react-router-dom'; import classNames from 'classnames'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, useIntl } from 'react-intl'; import { generateEditResourceUrl } from '@common/helpers/navigation.helper'; import { useNavigateToEditPage } from '@common/hooks/useNavigateToEditPage'; import { Button, ButtonType } from '@components/Button'; @@ -28,6 +28,7 @@ export const WorkDetailsCard: FC = ({ handleOpenPreview, titles, }) => { + const { formatMessage } = useIntl(); const { navigateToEditPage } = useNavigateToEditPage(); const title = getTitle(titles); const creatorName = contributors?.find(({ isCreator }) => isCreator)?.name; @@ -39,7 +40,12 @@ export const WorkDetailsCard: FC = ({ return (
-
diff --git a/translations/ui-linked-data/en.json b/translations/ui-linked-data/en.json index 1624e6db..f4b85b7d 100644 --- a/translations/ui-linked-data/en.json +++ b/translations/ui-linked-data/en.json @@ -186,8 +186,18 @@ "ld.selectBrowseOption": "Select a browse option", "ld.searchQueryWouldBeHere": "{query} would be here", "ld.continue": "Continue", + "ld.aria.modal.close": "Close {modalKind} modal", + "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", + "ld.aria.advancedSearch.identifier": "Advanced search row identifier", "ld.aria.filters.select": "Select search identifiers", + "ld.aria.listEntry.open": "Open collapsible list entry", + "ld.aria.listEntry.close": "Close collapsible list entry", "ld.aria.filters.textbox": "Search query textbox", + "ld.aria.table.selectRow": "Select table row", + "ld.aria.sections.openResourcePreview": "Open resource preview section", + "ld.aria.sections.closeResourcePreview": "Close resource preview section", "ld.aria.filters.reset": "Reset filters button", "ld.aria.filters.reset.announce": "Search field and filters are reset", "ld.duplicateImportWarn": "Duplicate import warning",