Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6.8k
perf(cdk/overlay): add event listeners for overlay dispatchers outside of zone#23962
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
zarend
merged 1 commit into
angular:master
from
arturovt:perf/overlay-keyboard-dispatcherFeb 3, 2022
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
30 changes: 25 additions & 5 deletions
30 src/cdk/overlay/dispatchers/overlay-keyboard-dispatcher.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| import {TestBed, inject} from '@angular/core/testing'; | ||
| import {dispatchKeyboardEvent} from '../../testing/private'; | ||
| import {ESCAPE} from '@angular/cdk/keycodes'; | ||
| import {Component} from '@angular/core'; | ||
| import {ApplicationRef, Component} from '@angular/core'; | ||
| import {OverlayModule, Overlay} from '../index'; | ||
| import {OverlayKeyboardDispatcher} from './overlay-keyboard-dispatcher'; | ||
| import {ComponentPortal} from '@angular/cdk/portal'; | ||
| describe('OverlayKeyboardDispatcher', () => { | ||
| let appRef: ApplicationRef; | ||
| let keyboardDispatcher: OverlayKeyboardDispatcher; | ||
| let overlay: Overlay; | ||
| @@ -16,10 +17,14 @@ describe('OverlayKeyboardDispatcher', () => { | ||
| declarations: [TestComponent], | ||
| }); | ||
| inject([OverlayKeyboardDispatcher, Overlay], (kbd: OverlayKeyboardDispatcher, o: Overlay) => { | ||
| keyboardDispatcher = kbd; | ||
| overlay = o; | ||
| })(); | ||
| inject( | ||
| [ApplicationRef, OverlayKeyboardDispatcher, Overlay], | ||
| (ar: ApplicationRef, kbd: OverlayKeyboardDispatcher, o: Overlay) => { | ||
| appRef = ar; | ||
| keyboardDispatcher = kbd; | ||
| overlay = o; | ||
| }, | ||
| )(); | ||
| }); | ||
| it('should track overlays in order as they are attached and detached', () => { | ||
| @@ -179,6 +184,21 @@ describe('OverlayKeyboardDispatcher', () => { | ||
| expect(overlayTwoSpy).not.toHaveBeenCalled(); | ||
| expect(overlayOneSpy).toHaveBeenCalled(); | ||
| }); | ||
| it('should not run change detection if there are no `keydownEvents` observers', () => { | ||
| spyOn(appRef, 'tick'); | ||
| const overlayRef = overlay.create(); | ||
| keyboardDispatcher.add(overlayRef); | ||
crisbeto marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| expect(appRef.tick).toHaveBeenCalledTimes(0); | ||
| dispatchKeyboardEvent(document.body, 'keydown', ESCAPE); | ||
| expect(appRef.tick).toHaveBeenCalledTimes(0); | ||
| overlayRef.keydownEvents().subscribe(); | ||
| dispatchKeyboardEvent(document.body, 'keydown', ESCAPE); | ||
| expect(appRef.tick).toHaveBeenCalledTimes(1); | ||
crisbeto marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }); | ||
| }); | ||
| @Component({ | ||
25 changes: 21 additions & 4 deletions
25 src/cdk/overlay/dispatchers/overlay-keyboard-dispatcher.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 69 additions & 3 deletions
72 src/cdk/overlay/dispatchers/overlay-outside-click-dispatcher.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 28 additions & 7 deletions
35 src/cdk/overlay/dispatchers/overlay-outside-click-dispatcher.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.