Skip to content

Commit 527da8f

Browse files
committed
[ACS-7363] Search - Advanced Filters - visual bugs in Logic and Properties filters
1 parent 9cb01e2 commit 527da8f

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

lib/content-services/src/lib/search/components/search-chip-autocomplete-input/search-chip-autocomplete-input.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
placeholder="{{ placeholder | translate }}"
2020
aria-controls="adf-search-chip-autocomplete"
2121
#optionInput
22+
#autocompleteTrigger="matAutocompleteTrigger"
2223
[formControl]="formCtrl"
2324
[matAutocomplete]="auto"
2425
[matChipInputFor]="chipList"
2526
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
2627
[attr.aria-label]="placeholder | translate"
2728
class="adf-search-properties-file-input"
2829
(matChipInputTokenEnd)="add($event)"
29-
(blur)="activeAnyOption = false"
30+
(blur)="activeAnyOption = false; autocompleteTrigger.closePanel()"
3031
data-automation-id="adf-search-chip-autocomplete-input">
3132
</mat-chip-grid>
3233
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" id="adf-search-chip-autocomplete"

lib/content-services/src/lib/search/components/search-logical-filter/search-logical-filter.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<input type="text"
55
[(ngModel)]="searchCondition[LogicalSearchFields[field]]"
66
placeholder="{{ ('SEARCH.LOGICAL_SEARCH.' + field + '_HINT') | translate }}"
7-
[attr.aria-label]="('SEARCH.LOGICAL_SEARCH.' + field + '_HINT') | translate"
8-
(change)="onInputChange()"/>
7+
[attr.aria-label]="('SEARCH.LOGICAL_SEARCH.' + field + '_HINT') | translate"/>
98
</div>
109
</div>

lib/content-services/src/lib/search/components/search-logical-filter/search-logical-filter.component.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ describe('SearchLogicalFilterComponent', () => {
9999
expect(component.hasValidValue()).toBeTrue();
100100
});
101101

102-
it('should update display value after phrases changes', () => {
102+
it('should update display value after phrases changes and user user clicks submit', () => {
103103
spyOn(component.displayValue$, 'next');
104104
enterNewPhrase('test2', 0);
105+
component.submitValues();
105106
expect(component.displayValue$.next).toHaveBeenCalledOnceWith(` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[0]}: test2`);
106107
});
107108

108-
it('should have correct display value after each field has at least one phrase', () => {
109+
it('should have correct display value after each field has at least one phrase and user clicks submit', () => {
109110
spyOn(component.displayValue$, 'next');
110111
enterNewPhrase('test1', 0);
111112
enterNewPhrase('test2', 1);
@@ -115,6 +116,7 @@ describe('SearchLogicalFilterComponent', () => {
115116
const displayVal2 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[1]}: test2`;
116117
const displayVal3 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[2]}: test3`;
117118
const displayVal4 = ` SEARCH.LOGICAL_SEARCH.${Object.keys(LogicalSearchFields)[3]}: test4`;
119+
component.submitValues();
118120
expect(component.displayValue$.next).toHaveBeenCalledWith(displayVal1 + displayVal2 + displayVal4 + displayVal3);
119121
});
120122

lib/content-services/src/lib/search/components/search-logical-filter/search-logical-filter.component.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export enum LogicalSearchFields {
2929
MATCH_EXACT = 'matchExact'
3030
}
3131

32-
export type LogicalSearchConditionEnumValuedKeys = { [T in LogicalSearchFields]: string; };
32+
export type LogicalSearchConditionEnumValuedKeys = { [T in LogicalSearchFields]: string };
3333
// eslint-disable-next-line @typescript-eslint/no-empty-interface
3434
export interface LogicalSearchCondition extends LogicalSearchConditionEnumValuedKeys {}
3535

@@ -55,20 +55,16 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
5555
this.clearSearchInputs();
5656
}
5757

58-
onInputChange() {
59-
this.updateDisplayValue();
60-
}
61-
6258
submitValues() {
6359
if (this.hasValidValue() && this.id && this.context && this.settings && this.settings.field) {
6460
this.updateDisplayValue();
65-
const fields = this.settings.field.split(',').map((field) => field += ':');
61+
const fields = this.settings.field.split(',').map((field) => (field += ':'));
6662
let query = '';
6763
Object.keys(this.searchCondition).forEach((key) => {
6864
if (this.searchCondition[key] !== '') {
6965
let connector = '';
7066
let subQuery = '';
71-
switch(key) {
67+
switch (key) {
7268
case LogicalSearchFields.MATCH_ALL:
7369
case LogicalSearchFields.MATCH_EXACT:
7470
connector = 'AND';
@@ -88,12 +84,16 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
8884
if (key === LogicalSearchFields.MATCH_EXACT) {
8985
fieldQuery += field + '"' + this.searchCondition[key].trim() + '"';
9086
} else {
91-
this.searchCondition[key].split(' ').filter((condition: string) => condition !== '').forEach((phrase: string) => {
92-
const refinedPhrase = '"' + phrase + '"';
93-
fieldQuery += fieldQuery === '(' ?
94-
`${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}` :
95-
` ${connector} ${field}${refinedPhrase}`;
96-
});
87+
this.searchCondition[key]
88+
.split(' ')
89+
.filter((condition: string) => condition !== '')
90+
.forEach((phrase: string) => {
91+
const refinedPhrase = '"' + phrase + '"';
92+
fieldQuery +=
93+
fieldQuery === '('
94+
? `${key === LogicalSearchFields.EXCLUDE ? 'NOT ' : ''}${field}${refinedPhrase}`
95+
: ` ${connector} ${field}${refinedPhrase}`;
96+
});
9797
}
9898
subQuery += `${fieldQuery})`;
9999
});
@@ -103,6 +103,8 @@ export class SearchLogicalFilterComponent implements SearchWidget, OnInit {
103103
});
104104
this.context.queryFragments[this.id] = query;
105105
this.context.update();
106+
} else {
107+
this.reset();
106108
}
107109
}
108110

0 commit comments

Comments
 (0)