Skip to content

Commit

Permalink
fix(box): remove focus outline
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdavies73 committed Oct 10, 2024
1 parent dfba661 commit f1d6537
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/box/box.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,21 @@ test.describe("should render Box component", () => {
"rgba(0, 20, 30, 0.04) 0px 10px 40px 0px, rgba(0, 20, 30, 0.1) 0px 50px 80px 0px"
);
});

test("should render without a visible focus outline, when focused with a set `tabIndex`", async ({
mount,
page,
}) => {
await mount(<Default tabIndex={0} />);
const boxElement = getDataElementByValue(page, "box");

await boxElement.focus();
await expect(boxElement).toBeFocused();
await expect(boxElement).toHaveCSS(
"outline",
"rgb(255, 255, 255) none 0px"
);
});
});

test.describe("Accessibility tests for Box", () => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/box/box.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const StyledBox = styled.div<BoxProps>`
${grid}
${calculatePosition}
:focus {
outline: none;
}
${({ theme, borderRadius = "borderRadius000" }) =>
!theme.roundedCornersOptOut &&
css`
Expand Down

0 comments on commit f1d6537

Please sign in to comment.