diff --git a/__tests__/src/components/WindowTopMenuButton.test.js b/__tests__/src/components/WindowTopMenuButton.test.js index baf91aef5..f49934dbe 100644 --- a/__tests__/src/components/WindowTopMenuButton.test.js +++ b/__tests__/src/components/WindowTopMenuButton.test.js @@ -47,6 +47,6 @@ describe('WindowTopMenuButton', () => { render(); await user.click(screen.getByLabelText('Window views & thumbnail display')); // when 'open' is true, aria-owns is set to the id of the window - expect(screen.getByLabelText('Window views & thumbnail display')).toHaveAttribute('aria-owns', 'window-menu_xyz'); // eslint-disable-line testing-library/no-node-access + expect(screen.getByLabelText('Window views & thumbnail display')).toHaveAttribute('aria-owns'); // eslint-disable-line testing-library/no-node-access }); }); diff --git a/__tests__/src/components/WorkspaceOptionsMenu.test.js b/__tests__/src/components/WorkspaceOptionsMenu.test.js index 3d71aab0d..64da09529 100644 --- a/__tests__/src/components/WorkspaceOptionsMenu.test.js +++ b/__tests__/src/components/WorkspaceOptionsMenu.test.js @@ -48,18 +48,18 @@ describe('WorkspaceOptionsMenu', () => { it('renders the export dialog when export option is clicked', async () => { render(); - expect(document.querySelector('#workspace-export')).not.toBeInTheDocument(); // eslint-disable-line testing-library/no-node-access + expect(screen.queryByRole('heading', { name: 'Export workspace' })).not.toBeInTheDocument(); - await user.click(screen.getAllByRole('menuitem')[0]); - expect(document.querySelector('#workspace-export')).toBeInTheDocument(); // eslint-disable-line testing-library/no-node-access + await user.click(screen.getByRole('menuitem', { name: 'Export workspace' })); + expect(screen.getByRole('heading', { name: 'Export workspace' })).toBeInTheDocument(); }); - it('renders the import dialog when imporrt option is clicked', async () => { + it('renders the import dialog when import option is clicked', async () => { render(); - expect(document.querySelector('#workspace-import')).not.toBeInTheDocument(); // eslint-disable-line testing-library/no-node-access + expect(screen.queryByRole('heading', { name: 'Import workspace' })).not.toBeInTheDocument(); - await user.click(screen.getAllByRole('menuitem')[1]); - expect(document.querySelector('#workspace-import')).toBeInTheDocument(); // eslint-disable-line testing-library/no-node-access + await user.click(screen.getByRole('menuitem', { name: 'Import workspace' })); + expect(screen.getByRole('heading', { name: 'Import workspace' })).toBeInTheDocument(); }); it('fires the correct callbacks on menu close', async () => { diff --git a/src/components/ManifestRelatedLinks.js b/src/components/ManifestRelatedLinks.js index 2169b68c1..305433a77 100644 --- a/src/components/ManifestRelatedLinks.js +++ b/src/components/ManifestRelatedLinks.js @@ -4,6 +4,7 @@ import Typography from '@mui/material/Typography'; import Link from '@mui/material/Link'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; +import { useId } from 'react'; import CollapsibleSection from '../containers/CollapsibleSection'; import ns from '../config/css-ns'; import { PluginHook } from './PluginHook'; @@ -28,18 +29,19 @@ export function ManifestRelatedLinks({ ...rest }) { const { t } = useTranslation(); + const titleId = useId(); + const pluginProps = { homepage, id, manifestUrl, related, renderings, seeAlso, t, ...rest, }; return ( diff --git a/src/components/SearchHit.js b/src/components/SearchHit.js index c656f4d14..de79d2126 100644 --- a/src/components/SearchHit.js +++ b/src/components/SearchHit.js @@ -1,4 +1,4 @@ -import { useEffect, useMemo } from 'react'; +import { useEffect, useId, useMemo } from 'react'; import { useEffectEvent } from 'use-effect-event'; import PropTypes from 'prop-types'; import Button from '@mui/material/Button'; @@ -86,11 +86,12 @@ export function SearchHit({ ); }); + const canvasLabelHtmlId = useId(); + if (focused && !selected) return null; const renderedHit = focused ? hit : hit && truncatedHit; const truncated = hit && (renderedHit.before !== hit.before || renderedHit.after !== hit.after); - const canvasLabelHtmlId = `${companionWindowId}-${index}`; const ownerState = { adjacent, focused, selected, windowSelected, }; diff --git a/src/components/WindowListButton.js b/src/components/WindowListButton.js index 3134fa745..451cf2bba 100644 --- a/src/components/WindowListButton.js +++ b/src/components/WindowListButton.js @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useId, useState } from 'react'; import PropTypes from 'prop-types'; import BookmarksIcon from '@mui/icons-material/BookmarksSharp'; import { useTranslation } from 'react-i18next'; @@ -11,6 +11,7 @@ import MiradorMenuButton from '../containers/MiradorMenuButton'; export function WindowListButton({ disabled = false, windowCount }) { const { t } = useTranslation(); const [windowListAnchor, setWindowListAnchor] = useState(null); + const id = useId(); /** */ const handleClose = () => { setWindowListAnchor(null); }; @@ -22,7 +23,7 @@ export function WindowListButton({ disabled = false, windowCount }) { diff --git a/src/components/WindowSideBarCanvasPanel.js b/src/components/WindowSideBarCanvasPanel.js index 59953f227..2b30297c4 100644 --- a/src/components/WindowSideBarCanvasPanel.js +++ b/src/components/WindowSideBarCanvasPanel.js @@ -1,4 +1,4 @@ -import { useRef } from 'react'; +import { useId, useRef } from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import Tabs from '@mui/material/Tabs'; @@ -49,6 +49,7 @@ export function WindowSideBarCanvasPanel({ }) { const { t } = useTranslation(); const containerRef = useRef(); + const tabPanelId = useId(); /** */ const handleSequenceChange = (event) => { @@ -126,15 +127,15 @@ export function WindowSideBarCanvasPanel({ textColor="primary" > {showToc && ( - } /> + } /> )} - } /> - } /> + } /> + } /> )} > -
+
{ collection && (