Skip to content

Commit fd44683

Browse files
Merge pull request #2 from donnieberg/modal-role
Make modal role='alertdialog' if it is not dismissible
2 parents b3b6e1f + 5d4ac7b commit fd44683

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

components/modal/__tests__/modal.browser-test.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ describe('SLDSModal: ', function () {
127127
});
128128
});
129129

130+
describe('Proper HTML markup', () => {
131+
it('dismissible modal has role=dialog', () => {
132+
const cmp = getModal({
133+
isOpen: true
134+
});
135+
const modal = getModalNode(document.body);
136+
const role = modal.getAttribute('role');
137+
expect(role).to.equal('dialog');
138+
});
139+
140+
it('non-dismissible modal has role=alertdialog', () => {
141+
const cmp = getModal({
142+
isOpen: true,
143+
dismissible: false
144+
});
145+
const modal = getModalNode(document.body);
146+
const role = modal.getAttribute('role');
147+
expect(role).to.equal('alertdialog');
148+
});
149+
});
150+
130151
describe('Open with custom header and header className', () => {
131152
let modal;
132153

components/modal/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class Modal extends React.Component {
239239
'slds-modal--prompt': this.isPrompt(),
240240
})}
241241
onClick={this.dismissModalOnClickOutside}
242-
role="dialog"
242+
role={this.props.dismissible ? "dialog" : "alertdialog"}
243243
>
244244
<div
245245
className={classNames(

0 commit comments

Comments
 (0)