Skip to content

fix(overlay): stop using capture phase for overlay keyboard handling #16019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -81,7 +81,7 @@ describe('OverlayKeyboardDispatcher', () => {
keyboardDispatcher.add(overlayRef);
dispatchKeyboardEvent(button, 'keydown', ESCAPE);

expect(spy).toHaveBeenCalled();
expect(spy).not.toHaveBeenCalled();

button.parentNode!.removeChild(button);
});
Expand Down Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down