diff --git a/aio/src/app/app.component.spec.ts b/aio/src/app/app.component.spec.ts index b27951a1ff..ca60257b08 100644 --- a/aio/src/app/app.component.spec.ts +++ b/aio/src/app/app.component.spec.ts @@ -721,6 +721,15 @@ describe('AppComponent', () => { expect(component.showSearchResults).toBe(false); }); + it('should clear "only" the search query param from the URL', () => { + // Mock out the current state of the URL query params + locationService.search.and.returnValue({ a: 'some-A', b: 'some-B', search: 'some-C'}); + // docViewer is a commonly-clicked, non-search element + docViewer.click(); + // Check that the query params were updated correctly + expect(locationService.setSearch).toHaveBeenCalledWith('', { a: 'some-A', b: 'some-B', search: undefined }); + }); + it('should not intercept clicks on the searchResults', () => { component.showSearchResults = true; fixture.detectChanges(); diff --git a/aio/src/app/app.component.ts b/aio/src/app/app.component.ts index a15c4ca3fe..7353f7480c 100644 --- a/aio/src/app/app.component.ts +++ b/aio/src/app/app.component.ts @@ -384,7 +384,7 @@ export class AppComponent implements OnInit { hideSearchResults() { this.showSearchResults = false; - this.locationService.setSearch('', {}); + this.locationService.setSearch('', { ...this.locationService.search(), search: undefined }); } focusSearchBox() {