Skip to content

Commit f055a99

Browse files
authored
[PRM-155] WCAG 4.1.3 status messages: ARF download starts/completes without announcing (#650)
* Add download has started span to arf download * Remove incorrect labelling * Remove incorrect labelling * adds assertive aria * Adds assertive aria to finished download state * adds download state announcer div * Shows download status * Adds class to aria div * Makes download status announce on update * Removes visually hidden for testing purposes * Sets reader to assertive * move aria div * Hides aria div * move Aria div to top of screen * Changed aria announcement to polite
1 parent 4d6b913 commit f055a99

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

app/src/components/blocks/_arf/documentSearchResultsOptions/DocumentSearchResultsOptions.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ const DocumentSearchResultsOptions = (props: Props) => {
3131
filename: '',
3232
});
3333
const linkRef = useRef<HTMLAnchorElement | null>(null);
34+
const [statusMessage, setStatusMessage] = useState('');
35+
useEffect(() => {
36+
switch (props.downloadState) {
37+
case SUBMISSION_STATE.PENDING:
38+
setStatusMessage('Download in progress.');
39+
break;
40+
case SUBMISSION_STATE.SUCCEEDED:
41+
setStatusMessage('Download complete.');
42+
break;
43+
case SUBMISSION_STATE.FAILED:
44+
setStatusMessage('Download failed.');
45+
break;
46+
default:
47+
setStatusMessage('');
48+
}
49+
}, [props.downloadState]);
3450

3551
useEffect(() => {
3652
if (linkRef.current && linkAttributes.url) {
@@ -70,6 +86,14 @@ const DocumentSearchResultsOptions = (props: Props) => {
7086

7187
return (
7288
<>
89+
<div
90+
id="download-status"
91+
aria-live="polite"
92+
role="status"
93+
className="nhsuk-u-visually-hidden"
94+
>
95+
{statusMessage}
96+
</div>
7397
<div className="search-result-spinner-div">
7498
{props.downloadState === SUBMISSION_STATE.PENDING ? (
7599
<SpinnerButton

0 commit comments

Comments
 (0)