Skip to content

Commit 1fd4804

Browse files
committed
Prevent tab index in editor
1 parent a8d11a7 commit 1fd4804

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/Tabs.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default (dc, {
77
const el = this;
88
const classTabActive = props.classactive;
99
const selectorTab = props.selectortab;
10-
const { history } = window;
10+
const { history, _isEditor } = window;
1111
const attrTabindex = 'tabIndex';
1212
const attrSelected = 'ariaSelected';
1313
const roleTab = '[role=tab]';
@@ -25,17 +25,18 @@ export default (dc, {
2525
}
2626

2727
const getAllTabs = () => el.querySelectorAll(roleTab);
28+
const upTabIdx = (item, val) => !_isEditor && (item[attrTabindex] = val);
2829

2930
const activeTab = (tabEl) => {
3031
each(getAllTabs(), (item) => {
3132
item.className = item.className.replace(classTabActive, '').trim();
32-
item[attrTabindex] = '-1';
3333
item[attrSelected] = 'false';
34+
upTabIdx(item, '-1');
3435
});
3536
hideContents();
3637
tabEl.className += ' ' + classTabActive;
37-
tabEl[attrTabindex] = '0';
3838
tabEl[attrSelected] = 'true';
39+
upTabIdx(tabEl, '0');
3940
const tabContentId = tabEl.getAttribute(selectorTab);
4041
const tabContent = tabContentId && el.querySelector(`#${tabContentId}`);
4142
tabContent && (tabContent.hidden = false);

0 commit comments

Comments
 (0)