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:
parent
30f12f2887
commit
4001bb44d2
|
@ -742,7 +742,7 @@ describe('AppComponent', () => {
|
||||||
expect(component.showSearchResults).toBe(true);
|
expect(component.showSearchResults).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not intercept clicks om the searchBox', () => {
|
it('should not intercept clicks on the searchBox', () => {
|
||||||
component.showSearchResults = true;
|
component.showSearchResults = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
@ -752,6 +752,11 @@ describe('AppComponent', () => {
|
||||||
|
|
||||||
expect(component.showSearchResults).toBe(true);
|
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', () => {
|
describe('keyup handling', () => {
|
||||||
|
|
|
@ -389,7 +389,10 @@ export class AppComponent implements OnInit {
|
||||||
|
|
||||||
hideSearchResults() {
|
hideSearchResults() {
|
||||||
this.showSearchResults = false;
|
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() {
|
focusSearchBox() {
|
||||||
|
|
Loading…
Reference in New Issue