Skip to content

Commit 311e8c6

Browse files
committed
refactor: move tabIndex assigment to markdown-toolbar
Now markdown-toolbar manages all tabindex assignment, which means it will also assign tabindexes to `data-md-button` elements, as needed.
1 parent 538ff34 commit 311e8c6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ class MarkdownButtonElement extends HTMLElement {
3333
}
3434

3535
connectedCallback() {
36-
if (!this.hasAttribute('tabindex')) {
37-
this.setAttribute('tabindex', '-1')
38-
}
39-
4036
if (!this.hasAttribute('role')) {
4137
this.setAttribute('role', 'button')
4238
}
@@ -251,8 +247,11 @@ class MarkdownToolbarElement extends HTMLElement {
251247
this.field.addEventListener('keydown', fn)
252248
shortcutListeners.set(this, fn)
253249
}
254-
const firstTabIndex = getButtons(this)[0]
255-
if (firstTabIndex) firstTabIndex.setAttribute('tabindex', '0')
250+
let tabindex = '0'
251+
for (const button of getButtons(this)) {
252+
button.setAttribute('tabindex', tabindex)
253+
if (tabindex === '0') tabindex = '-1'
254+
}
256255
}
257256

258257
disconnectedCallback() {

0 commit comments

Comments
 (0)