fix(docs-infra): don't call setSearch when not clicking in the searchBox and no searchResults (#26590)

Fix to call locationService.setSearch less often to avoid unnecessary
downloading of favicons

Fixes #26544

PR Close #26590
This commit is contained in:
onlyflix 2018-10-19 16:09:28 +02:00 committed by Jason Aden
parent 30f12f2887
commit 4001bb44d2
2 changed files with 10 additions and 2 deletions

View File

@ -742,7 +742,7 @@ describe('AppComponent', () => {
expect(component.showSearchResults).toBe(true);
});
it('should not intercept clicks om the searchBox', () => {
it('should not intercept clicks on the searchBox', () => {
component.showSearchResults = true;
fixture.detectChanges();
@ -752,6 +752,11 @@ describe('AppComponent', () => {
expect(component.showSearchResults).toBe(true);
});
it('should not call `locationService.setSearch` when searchResults are not shown', () => {
docViewer.click();
expect(locationService.setSearch).not.toHaveBeenCalled();
});
});
describe('keyup handling', () => {

View File

@ -389,7 +389,10 @@ export class AppComponent implements OnInit {
hideSearchResults() {
this.showSearchResults = false;
this.locationService.setSearch('', { ...this.locationService.search(), search: undefined });
const oldSearch = this.locationService.search();
if (oldSearch.search !== undefined) {
this.locationService.setSearch('', { ...oldSearch, search: undefined });
}
}
focusSearchBox() {