Skip to content

Commit 8bcad3d

Browse files
committed
Don't set tabindex=0 when data-no-focus
1 parent ce94934 commit 8bcad3d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,11 @@ class MarkdownToolbarElement extends HTMLElement {
324324
if (!this.hasAttribute('role')) {
325325
this.setAttribute('role', 'toolbar')
326326
}
327-
this.addEventListener('keydown', focusKeydown)
328-
this.setAttribute('tabindex', '0')
329-
this.addEventListener('focus', onToolbarFocus, {once: true})
327+
if (!this.hasAttribute('data-no-focus')) {
328+
this.addEventListener('keydown', focusKeydown)
329+
this.setAttribute('tabindex', '0')
330+
this.addEventListener('focus', onToolbarFocus, {once: true})
331+
}
330332
this.addEventListener('keydown', keydown(applyFromToolbar))
331333
this.addEventListener('click', applyFromToolbar)
332334
}
@@ -349,7 +351,6 @@ class MarkdownToolbarElement extends HTMLElement {
349351

350352
function onToolbarFocus({target}: FocusEvent) {
351353
if (!(target instanceof Element)) return
352-
if (target.hasAttribute('data-no-focus')) return
353354
target.removeAttribute('tabindex')
354355
let tabindex = '0'
355356
for (const button of getButtons(target)) {
@@ -366,7 +367,6 @@ function focusKeydown(event: KeyboardEvent) {
366367
if (key !== 'ArrowRight' && key !== 'ArrowLeft' && key !== 'Home' && key !== 'End') return
367368
const toolbar = event.currentTarget
368369
if (!(toolbar instanceof HTMLElement)) return
369-
if (toolbar.hasAttribute('data-no-focus')) return
370370
const buttons = getButtons(toolbar)
371371
const index = buttons.indexOf(event.target as HTMLElement)
372372
const length = buttons.length

0 commit comments

Comments
 (0)