@@ -324,9 +324,11 @@ class MarkdownToolbarElement extends HTMLElement {
324
324
if ( ! this . hasAttribute ( 'role' ) ) {
325
325
this . setAttribute ( 'role' , 'toolbar' )
326
326
}
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
+ }
330
332
this . addEventListener ( 'keydown' , keydown ( applyFromToolbar ) )
331
333
this . addEventListener ( 'click' , applyFromToolbar )
332
334
}
@@ -349,7 +351,6 @@ class MarkdownToolbarElement extends HTMLElement {
349
351
350
352
function onToolbarFocus ( { target} : FocusEvent ) {
351
353
if ( ! ( target instanceof Element ) ) return
352
- if ( target . hasAttribute ( 'data-no-focus' ) ) return
353
354
target . removeAttribute ( 'tabindex' )
354
355
let tabindex = '0'
355
356
for ( const button of getButtons ( target ) ) {
@@ -366,7 +367,6 @@ function focusKeydown(event: KeyboardEvent) {
366
367
if ( key !== 'ArrowRight' && key !== 'ArrowLeft' && key !== 'Home' && key !== 'End' ) return
367
368
const toolbar = event . currentTarget
368
369
if ( ! ( toolbar instanceof HTMLElement ) ) return
369
- if ( toolbar . hasAttribute ( 'data-no-focus' ) ) return
370
370
const buttons = getButtons ( toolbar )
371
371
const index = buttons . indexOf ( event . target as HTMLElement )
372
372
const length = buttons . length
0 commit comments