diff --git a/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.spec.ts b/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.spec.ts index aca87a42395..24c615b8223 100644 --- a/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.spec.ts +++ b/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.spec.ts @@ -69,7 +69,7 @@ describe('OverlayKeyboardDispatcher', () => { expect(overlayTwoSpy).toHaveBeenCalled(); }); - it('should dispatch keyboard events when propagation is stopped', () => { + it('should not dispatch keyboard events when propagation is stopped', () => { const overlayRef = overlay.create(); const spy = jasmine.createSpy('keyboard event spy'); const button = document.createElement('button'); @@ -81,7 +81,7 @@ describe('OverlayKeyboardDispatcher', () => { keyboardDispatcher.add(overlayRef); dispatchKeyboardEvent(button, 'keydown', ESCAPE); - expect(spy).toHaveBeenCalled(); + expect(spy).not.toHaveBeenCalled(); button.parentNode!.removeChild(button); }); @@ -137,10 +137,10 @@ describe('OverlayKeyboardDispatcher', () => { spyOn(body, 'removeEventListener'); keyboardDispatcher.add(overlayRef); - expect(body.addEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function), true); + expect(body.addEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function)); overlayRef.dispose(); - expect(body.removeEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function), true); + expect(body.removeEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function)); }); it('should skip overlays that do not have keydown event subscriptions', () => { diff --git a/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.ts b/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.ts index 9a6783b73cf..e4571e72e6c 100644 --- a/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.ts +++ b/src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.ts @@ -47,7 +47,7 @@ export class OverlayKeyboardDispatcher implements OnDestroy { // Lazily start dispatcher once first overlay is added if (!this._isAttached) { - this._document.body.addEventListener('keydown', this._keydownListener, true); + this._document.body.addEventListener('keydown', this._keydownListener); this._isAttached = true; } @@ -71,7 +71,7 @@ export class OverlayKeyboardDispatcher implements OnDestroy { /** Detaches the global keyboard event listener. */ private _detach() { if (this._isAttached) { - this._document.body.removeEventListener('keydown', this._keydownListener, true); + this._document.body.removeEventListener('keydown', this._keydownListener); this._isAttached = false; } }