Merge pull request #308 from yqrashawn/tab-role

fix(tabs): add role="button" to tab for a11y
This commit is contained in:
witt
2020-07-02 20:38:38 +08:00
committed by GitHub
2 changed files with 3 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Tabs should render correctly 1`] = `
"<div class=\\"tabs \\"><header class=\\"\\"><div class=\\"tab \\">label1</div><div class=\\"tab \\">label2</div></header><div class=\\"content\\"></div><style>
"<div class=\\"tabs \\"><header class=\\"\\"><div class=\\"tab \\" role=\\"button\\">label1</div><div class=\\"tab \\" role=\\"button\\">label2</div></header><div class=\\"content\\"></div><style>
.tabs {
width: initial;
}
@@ -76,7 +76,7 @@ exports[`Tabs should render correctly 1`] = `
`;
exports[`Tabs should work correctly with different styles 1`] = `
"<div class=\\"tabs \\"><header class=\\"hide-divider\\"><div class=\\"tab \\">label1</div></header><div class=\\"content\\"></div><style>
"<div class=\\"tabs \\"><header class=\\"hide-divider\\"><div class=\\"tab \\" role=\\"button\\">label1</div></header><div class=\\"content\\"></div><style>
.tabs {
width: initial;
}

View File

@@ -76,6 +76,7 @@ const Tabs: React.FC<React.PropsWithChildren<TabsProps>> = ({
className={`tab ${selfValue === item.value ? 'active' : ''} ${
item.disabled ? 'disabled' : ''
}`}
role="button"
key={item.value + index}
onClick={() => clickHandler(item)}>
{item.label}