File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 55 */
66import { AriaModalController } from '@vaadin/a11y-base/src/aria-modal-controller.js' ;
77import { FocusTrapController } from '@vaadin/a11y-base/src/focus-trap-controller.js' ;
8+ import { isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js' ;
89import { animationFrame } from '@vaadin/component-base/src/async.js' ;
910import { Debouncer } from '@vaadin/component-base/src/debounce.js' ;
1011import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js' ;
@@ -443,7 +444,7 @@ export const AppLayoutMixin = (superclass) =>
443444 // Move focus to the drawer toggle when closing the drawer.
444445 const toggle = this . querySelector ( 'vaadin-drawer-toggle' ) ;
445446 if ( toggle ) {
446- toggle . focus ( ) ;
447+ toggle . focus ( { focusVisible : isKeyboardActive ( ) } ) ;
447448 }
448449 }
449450
Original file line number Diff line number Diff line change 44 esc ,
55 fixtureSync ,
66 makeSoloTouchEvent ,
7+ mousedown ,
78 nextFrame ,
89 nextRender ,
910 nextResize ,
@@ -459,6 +460,21 @@ describe('vaadin-app-layout', () => {
459460 expect ( spy . called ) . to . be . false ;
460461 } ) ;
461462
463+ it ( 'should focus the drawer toggle with focusVisible: false on closing with mouse' , async ( ) => {
464+ const spy = sinon . spy ( toggle , 'focus' ) ;
465+ mousedown ( document . body ) ;
466+ layout . drawerOpened = false ;
467+ await nextFrame ( ) ;
468+ expect ( spy . firstCall . args [ 0 ] ) . to . eql ( { focusVisible : false } ) ;
469+ } ) ;
470+
471+ it ( 'should focus the drawer toggle with focusVisible: true on closing with keyboard' , async ( ) => {
472+ const spy = sinon . spy ( toggle , 'focus' ) ;
473+ esc ( drawer ) ;
474+ await nextFrame ( ) ;
475+ expect ( spy . firstCall . args [ 0 ] ) . to . eql ( { focusVisible : true } ) ;
476+ } ) ;
477+
462478 it ( 'should remove drawer tabindex when it resizes from the overlay mode' , async ( ) => {
463479 expect ( drawer . hasAttribute ( 'tabindex' ) ) . to . be . true ;
464480
You can’t perform that action at this time.
0 commit comments