Skip to content

Commit d0f9e21

Browse files
committed
Add Aria label to Modal.tsx
1 parent 7f4a0a4 commit d0f9e21

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

packages/design-system/src/lib/components/modal/Modal.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ interface ModalProps {
1010
onHide: () => void
1111
centered?: boolean
1212
size?: 'sm' | 'lg' | 'xl'
13+
ariaLabel?: string
1314
}
1415

15-
function Modal({ show, onHide, centered, size, children }: PropsWithChildren<ModalProps>) {
16+
function Modal({
17+
show,
18+
onHide,
19+
centered,
20+
size,
21+
children,
22+
ariaLabel
23+
}: PropsWithChildren<ModalProps>) {
1624
return (
17-
<BSModal centered={centered} show={show} onHide={onHide} size={size}>
25+
<BSModal centered={centered} show={show} onHide={onHide} size={size} aria-label={ariaLabel}>
1826
{children}
1927
</BSModal>
2028
)

public/locales/en/dataset.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
"studyCompletionTip": "Relationship of the data collected to the amount of data coded and stored in the Dataset. Information as to why certain items of collected information were not included in the dataset or a specific data file should be provided."
185185
},
186186
"publish": {
187+
"title": "Publish Dataset",
187188
"draftQuestion": "Are you sure you want to publish this dataset? Once you do so, it must remain published.",
188189
"draftSubtext": "This version of the dataset will be published with the following terms:",
189190
"previouslyReleasedQuestion": "Are you sure you want to republish this dataset?",

src/sections/collection/edit-collection-dropdown/delete-collection-button/confirm-delete-collection-modal/ConfirmDeleteCollectionModal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ export const ConfirmDeleteCollectionModal = ({
2020
}: ConfirmDeleteCollectionModalProps) => {
2121
const { t: tShared } = useTranslation('shared')
2222
const { t } = useTranslation('collection')
23+
const modalTitle = t('deleteCollectionModal.title')
2324

2425
return (
25-
<Modal show={show} onHide={isDeletingCollection ? () => {} : handleClose} centered size="lg">
26+
<Modal
27+
ariaLabel={modalTitle}
28+
show={show}
29+
onHide={isDeletingCollection ? () => {} : handleClose}
30+
centered
31+
size="lg">
2632
<Modal.Header>
2733
<Modal.Title>{t('deleteCollectionModal.title')}</Modal.Title>
2834
</Modal.Header>

src/sections/dataset/dataset-action-buttons/edit-dataset-menu/delete-draft-dataset/ConfirmDeleteDraftDatasetModal.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ export const ConfirmDeleteDraftDatasetModal = ({
2020
}: ConfirmDeleteDraftDatasetModalProps) => {
2121
const { t: tShared } = useTranslation('shared')
2222
const { t } = useTranslation('dataset')
23+
const modalTitle = t('datasetActionButtons.editDataset.deleteDatasetModal.title')
2324

2425
return (
25-
<Modal show={show} onHide={isDeletingDataset ? () => {} : handleClose} centered size="lg">
26+
<Modal
27+
ariaLabel={modalTitle}
28+
show={show}
29+
onHide={isDeletingDataset ? () => {} : handleClose}
30+
centered
31+
size="lg">
2632
<Modal.Header>
27-
<Modal.Title>{t('datasetActionButtons.editDataset.deleteDatasetModal.title')}</Modal.Title>
33+
<Modal.Title>{modalTitle}</Modal.Title>
2834
</Modal.Header>
2935
<Modal.Body>
3036
<Stack gap={2}>

src/sections/dataset/deaccession-dataset/ConfirmationModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ export function ConfirmationModal({
1919
}: ConfirmationModalProps) {
2020
const { t } = useTranslation(['dataset', 'shared'])
2121
const isDeaccessioning = submissionStatus === SubmissionStatus.IsSubmitting
22+
const modalTitle = t('confirmDeaccession.title')
2223

2324
return (
24-
<Modal size={'lg'} show={show} onHide={onCancel}>
25+
<Modal ariaLabel={modalTitle} size={'lg'} show={show} onHide={onCancel}>
2526
<Modal.Header>
2627
<Modal.Title>{t('confirmDeaccession.title')}</Modal.Title>
2728
</Modal.Header>

src/sections/dataset/publish-dataset/PublishDatasetModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ export function PublishDatasetModal({
7979
)
8080
handleClose()
8181
}
82+
const modalTitle = t('publish.title')
8283

8384
return (
84-
<Modal show={show} onHide={handleClose} size="xl">
85+
<Modal show={show} onHide={handleClose} size="xl" ariaLabel={modalTitle}>
8586
<Modal.Header>
86-
<Modal.Title>Publish Dataset</Modal.Title>
87+
<Modal.Title>{t('publish.title')}</Modal.Title>
8788
</Modal.Header>
8889
<Modal.Body>
8990
<Stack direction="vertical">

0 commit comments

Comments
 (0)