Skip to content

Commit e846642

Browse files
author
Poltergeist
committed
fix(buttonbadge): change form button to button role
This changes the the element from a button to a span and is adding the `role="button"` attribute to the element.
1 parent f8154d4 commit e846642

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

packages/badge/components/badgeButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class BadgeButton extends React.PureComponent<IBadgeButtonProps, {}> {
3030
const { appearance, children, onClick, tabIndex } = this.props;
3131
const props = {
3232
onClick,
33+
role: "button",
3334
tabIndex,
3435
className: css`
3536
outline: none;
@@ -38,7 +39,7 @@ export class BadgeButton extends React.PureComponent<IBadgeButtonProps, {}> {
3839
`
3940
};
4041

41-
return <button {...props}>{children}</button>;
42+
return <span {...props}>{children}</span>;
4243
}
4344
}
4445

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,80 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`BadgeButton accept jsx as children 1`] = `
4-
<button
4+
<span
55
className="css-y5qucr"
66
onClick={[Function]}
7+
role="button"
78
tabIndex={-1}
89
>
910
<span>
1011
string
1112
</span>
12-
</button>
13+
</span>
1314
`;
1415

1516
exports[`BadgeButton danger 1`] = `
16-
<button
17+
<span
1718
className="css-aqlru0"
1819
onClick={[Function]}
20+
role="button"
1921
tabIndex={-1}
2022
>
2123
danger
22-
</button>
24+
</span>
2325
`;
2426

2527
exports[`BadgeButton default 1`] = `
26-
<button
28+
<span
2729
className="css-y5qucr"
2830
onClick={[Function]}
31+
role="button"
2932
tabIndex={-1}
3033
>
3134
default
32-
</button>
35+
</span>
3336
`;
3437

3538
exports[`BadgeButton outline 1`] = `
36-
<button
39+
<span
3740
className="css-j343ve"
3841
onClick={[Function]}
42+
role="button"
3943
tabIndex={-1}
4044
>
4145
outline
42-
</button>
46+
</span>
4347
`;
4448

4549
exports[`BadgeButton primary 1`] = `
46-
<button
50+
<span
4751
className="css-q2731u"
4852
onClick={[Function]}
53+
role="button"
4954
tabIndex={-1}
5055
>
5156
primary
52-
</button>
57+
</span>
5358
`;
5459

5560
exports[`BadgeButton success 1`] = `
56-
<button
61+
<span
5762
className="css-10v0ttp"
5863
onClick={[Function]}
64+
role="button"
5965
tabIndex={-1}
6066
>
6167
success
62-
</button>
68+
</span>
6369
`;
6470

6571
exports[`BadgeButton warning 1`] = `
66-
<button
72+
<span
6773
className="css-1qzzy6w"
6874
onClick={[Function]}
75+
role="button"
6976
tabIndex={-1}
7077
>
7178
warning
72-
</button>
79+
</span>
7380
`;

packages/badge/tests/badgeButton.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe("BadgeButton", () => {
9393
default
9494
</BadgeButton>
9595
);
96-
const element = wrapper.find("button").props();
96+
const element = wrapper.find("span").props();
9797
expect(element.tabIndex).toBe(10);
9898
});
9999

0 commit comments

Comments
 (0)