This repository was archived by the owner on Jan 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -168,8 +168,8 @@ class MDCDismissibleDrawerFoundation extends MDCFoundation {
168
168
169
169
if ( this . isClosing ( ) ) {
170
170
this . adapter_ . removeClass ( OPEN ) ;
171
- this . adapter_ . restoreFocus ( ) ;
172
171
this . closed ( ) ;
172
+ this . adapter_ . restoreFocus ( ) ;
173
173
this . adapter_ . notifyClose ( ) ;
174
174
} else {
175
175
this . adapter_ . focusActiveNavigationItem ( ) ;
Original file line number Diff line number Diff line change 21
21
* THE SOFTWARE.
22
22
*/
23
23
24
- import MDCDrawerAdapter from '../adapter' ;
25
24
import MDCDismissibleDrawerFoundation from '../dismissible/foundation' ;
26
25
27
26
/**
Original file line number Diff line number Diff line change @@ -273,3 +273,18 @@ test('#handleTransitionEnd doesn\'t do anything if event is emitted with a non-e
273
273
td . verify ( mockAdapter . notifyOpen ( ) , { times : 0 } ) ;
274
274
td . verify ( mockAdapter . notifyClose ( ) , { times : 0 } ) ;
275
275
} ) ;
276
+
277
+ test ( '#handleTransitionEnd calls .closed() before restoring the focus.' , ( ) => {
278
+ const { foundation, mockAdapter} = setupTest ( ) ;
279
+ foundation . closed = td . function ( ) ;
280
+
281
+ const mockEventTarget = bel `<div class="foo">bar</div>` ;
282
+ td . when ( mockAdapter . elementHasClass ( mockEventTarget , cssClasses . ROOT ) ) . thenReturn ( true ) ;
283
+ td . when ( mockAdapter . hasClass ( cssClasses . CLOSING ) ) . thenReturn ( true ) ;
284
+ const executionOrder = [ ] ;
285
+ td . when ( foundation . closed ( ) ) . thenDo ( ( ) => executionOrder . push ( 'closed' ) ) ;
286
+ td . when ( mockAdapter . restoreFocus ( ) ) . thenDo ( ( ) => executionOrder . push ( 'restoreFocus' ) ) ;
287
+ foundation . handleTransitionEnd ( { target : mockEventTarget } ) ;
288
+
289
+ assert . deepEqual ( executionOrder , [ 'closed' , 'restoreFocus' ] ) ;
290
+ } ) ;
You can’t perform that action at this time.
0 commit comments