Skip to content

Commit a4d25d6

Browse files
Add heading elements to dialog headers to improve accessibility (#1002)
Closes #998.
1 parent d7cd1ec commit a4d25d6

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

src/common/ConfirmDialog.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
AlertDialogHeader,
1313
AlertDialogOverlay,
1414
} from "@chakra-ui/modal";
15+
import { Text } from "@chakra-ui/react";
1516
import { ReactNode, useRef } from "react";
1617
import { FormattedMessage } from "react-intl";
1718

@@ -40,8 +41,10 @@ export const ConfirmDialog = ({
4041
>
4142
<AlertDialogOverlay>
4243
<AlertDialogContent>
43-
<AlertDialogHeader fontSize="lg" fontWeight="bold">
44-
{header}
44+
<AlertDialogHeader>
45+
<Text as="h2" fontSize="lg" fontWeight="bold">
46+
{header}
47+
</Text>
4548
</AlertDialogHeader>
4649
<AlertDialogBody>{body}</AlertDialogBody>
4750
<AlertDialogFooter>

src/common/GenericDialog.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ModalHeader,
1212
ModalOverlay,
1313
} from "@chakra-ui/modal";
14-
import { Button, HStack, Link } from "@chakra-ui/react";
14+
import { Button, HStack, Link, Text } from "@chakra-ui/react";
1515
import { ThemeTypings } from "@chakra-ui/styled-system";
1616
import { ReactNode } from "react";
1717
import { FormattedMessage } from "react-intl";
@@ -48,8 +48,10 @@ export const GenericDialog = ({
4848
<ModalContent minWidth="560px" my="auto">
4949
<ModalCloseButton />
5050
{header && (
51-
<ModalHeader fontSize="lg" fontWeight="bold">
52-
{header}
51+
<ModalHeader>
52+
<Text as="h2" fontSize="xl" fontWeight="bold">
53+
{header}
54+
</Text>
5355
</ModalHeader>
5456
)}
5557
<ModalBody>{body}</ModalBody>

src/common/InputDialog.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: MIT
55
*/
66
import { Button } from "@chakra-ui/button";
7-
import { Box, VStack } from "@chakra-ui/layout";
7+
import { Box, VStack, Text } from "@chakra-ui/layout";
88
import {
99
Modal,
1010
ModalBody,
@@ -76,8 +76,10 @@ export const InputDialog = <T,>({
7676
>
7777
<ModalOverlay>
7878
<ModalContent>
79-
<ModalHeader fontSize="lg" fontWeight="bold">
80-
{header}
79+
<ModalHeader>
80+
<Text as="h2" fontSize="lg" fontWeight="bold">
81+
{header}
82+
</Text>
8183
</ModalHeader>
8284
<ModalBody>
8385
<VStack>

src/common/ProgressDialog.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ModalOverlay,
1212
} from "@chakra-ui/modal";
1313
import { Progress } from "@chakra-ui/progress";
14-
import { VStack } from "@chakra-ui/react";
14+
import { Text, VStack } from "@chakra-ui/react";
1515
import { ReactNode } from "react";
1616

1717
const doNothing = () => {};
@@ -39,7 +39,11 @@ const ProgressDialog = ({ header, body, progress }: ProgressDialogProps) => {
3939
>
4040
<ModalOverlay />
4141
<ModalContent>
42-
<ModalHeader>{header}</ModalHeader>
42+
<ModalHeader>
43+
<Text as="h2" fontSize="xl" fontWeight="bold">
44+
{header}
45+
</Text>
46+
</ModalHeader>
4347
<ModalBody>
4448
<VStack
4549
spacing={4}

src/e2e/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ export class App {
742742
async confirmInputDialog(title: string): Promise<void> {
743743
const document = await this.document();
744744
await document.findByText(title, {
745-
selector: "header",
745+
selector: "h2",
746746
});
747747
}
748748

0 commit comments

Comments
 (0)