Skip to content

Commit 773b579

Browse files
committed
remove recent history when there is a result
1 parent 519b8af commit 773b579

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

apps/daffio/src/app/docs/search/components/search-modal/search-modal.component.html

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<daffio-docs-search-field [inputValue]="formControl"></daffio-docs-search-field>
22

33
@let recentQueries = recentQueries$ | async;
4-
@if (recentQueries?.length > 0) {
4+
@let results = docsResults$ | async;
5+
@let loading = loading$ | async;
6+
7+
@if (recentQueries?.length > 0 && !results?.length && !loading) {
58
<div class="daffio-docs-search-history">
69
<div class="daffio-docs-search-history__title">
710
Recent
@@ -11,7 +14,7 @@
1114
<li daffioDocsSearchResultItem class="daffio-docs-search-results__item">
1215
<a [routerLink]="result.id" (click)="onClick(result.id)">
1316
<div class="daffio-docs-search-results__result-wrapper">
14-
<fa-icon [icon]="RESULT_ICONS[result.kind]" [fixedWidth]="true"></fa-icon>
17+
<fa-icon [icon]="faClockRotateLeft" [fixedWidth]="true"></fa-icon>
1518
<div class="daffio-docs-search-results__result-package">
1619
<div class="daffio-docs-search-results__result">{{result.title || result.name}}</div>
1720
@if ('package' in result) {
@@ -27,8 +30,6 @@
2730
</div>
2831
}
2932

30-
@let results = docsResults$ | async;
31-
@let loading = loading$ | async;
3233
@if (results?.length > 0 || loading) {
3334
<ul class="daffio-docs-search-results" role="listbox">
3435
@for (result of results; track $index) {
@@ -48,17 +49,21 @@
4849
</li>
4950
}
5051
</ul>
51-
} @else {
52+
}
53+
54+
@if (formControl.value && !results?.length && !loading) {
5255
<div class="daffio-docs-search-results">
53-
@if (formControl.value) {
54-
<div class="daffio-docs-search-results__no-results">
55-
No results found
56-
</div>
57-
} @else {
58-
<div class="daffio-docs-search-results__start-screen">
59-
Start typing to see results
60-
</div>
61-
}
56+
<div class="daffio-docs-search-results__no-results">
57+
No results found
58+
</div>
59+
</div>
60+
}
61+
62+
@if (!formControl.value && !recentQueries?.length && !results?.length && !loading) {
63+
<div class="daffio-docs-search-results">
64+
<div class="daffio-docs-search-results__start-screen">
65+
Start typing to see results
66+
</div>
6267
</div>
6368
}
6469

apps/daffio/src/app/docs/search/components/search-modal/search-modal.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
ChangeDetectionStrategy,
66
Component,
77
DestroyRef,
8-
HostBinding,
98
OnInit,
109
QueryList,
1110
ViewChildren,
@@ -52,6 +51,7 @@ import { DaffioDocsSearchFooterComponent } from '../search-footer/search-footer.
5251
styleUrl: './search-modal.component.scss',
5352
changeDetection: ChangeDetectionStrategy.OnPush,
5453
host: {
54+
class: 'daffio-docs-search-modal',
5555
'(keydown)': 'onKeydown($event)',
5656
},
5757
imports: [
@@ -68,8 +68,6 @@ export class DaffioDocsSearchModalComponent implements AfterViewInit, OnInit {
6868
readonly faClockRotateLeft = faClockRotateLeft;
6969
readonly RESULT_ICONS = DAFF_DOCS_SEARCH_RESULT_ICONS;
7070

71-
@HostBinding('class.daffio-docs-search-modal') readonly class = true;
72-
7371
@ViewChildren(DaffioDocsSearchResultItemDirective) items: QueryList<DaffioDocsSearchResultItemDirective>;
7472

7573
recentQueries$: Observable<Array<DaffSearchDocsResult>>;

0 commit comments

Comments
 (0)