Skip to content

Commit

Permalink
fix(dialog, dialog-full-screen): address axe violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Parsium committed Feb 2, 2022
1 parent d5e07d9 commit 53167d8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DialogFullScreen = ({
onCancel,
contentRef,
help,
role = "region",
role = "dialog",
...rest
}) => {
const dialogRef = useRef();
Expand Down
17 changes: 17 additions & 0 deletions src/components/dialog-full-screen/dialog-full-screen.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,23 @@ describe("DialogFullScreen", () => {
});

describe("ARIA attributes", () => {
it("by default, set role to `dialog` and aria-modal to true", () => {
wrapper = mount(
<DialogFullScreen open onCancel={() => {}} onConfirm={() => {}} />
);

expect(
wrapper
.find("[data-element='dialog-full-screen']")
.first()
.prop("aria-modal")
).toBe(true);

expect(
wrapper.find("[data-element='dialog-full-screen']").first().prop("role")
).toBe("dialog");
});

describe("when a title is specified as string", () => {
it("then the container should have aria-labeledby attribute set to it's header's id", () => {
wrapper = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ and setting the `autoFocus` on the element you wish to be focused instead (click
This should be focused first now
</Button>
</div>
<Textbox value="Not Focused" />
<Textbox label="Not Focused" />
</DialogFullScreen>
<Button ml={2} onClick={() => setIsOpenTwo(true)}>
Open Demo using autoFocus
Expand All @@ -909,7 +909,7 @@ and setting the `autoFocus` on the element you wish to be focused instead (click
<Button onClick={() => setisOpenTwo(false)}>Not focused</Button>
<Button onClick={() => setisOpenTwo(false)}>Not focused</Button>
</div>
<Textbox autoFocus value="This should be focused first now" />
<Textbox label="This should be focused first now" autoFocus />
</DialogFullScreen>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/dialog/dialog.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ and setting the `autoFocus` on the element you wish to be focused instead (click
This should be focused first now
</Button>
</div>
<Textbox value="Not Focused" />
<Textbox label="Not focused" />
</Dialog>
<Button ml={2} onClick={() => setIsOpenTwo(true)}>
Open Demo using autoFocus
Expand All @@ -335,7 +335,7 @@ and setting the `autoFocus` on the element you wish to be focused instead (click
<Button onClick={() => setisOpenTwo(false)}>Not focused</Button>
<Button onClick={() => setisOpenTwo(false)}>Not focused</Button>
</div>
<Textbox autoFocus value="This should be focused first now" />
<Textbox autoFocus label="This should be focused first now" />
</Dialog>
</>
);
Expand Down

0 comments on commit 53167d8

Please sign in to comment.