Skip to content

Commit 61b886d

Browse files
authored
fix(combo/select): remove suffix dynamically (#15961)
1 parent dc51a26 commit 61b886d

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

projects/igniteui-angular/src/lib/combo/combo.common.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121
Output,
2222
QueryList,
2323
TemplateRef,
24-
ViewChild
24+
ViewChild,
25+
ViewChildren
2526
} from '@angular/core';
2627
import { AbstractControl, ControlValueAccessor, NgControl } from '@angular/forms';
2728
import { caseSensitive } from '@igniteui/material-icons-extended';
@@ -748,6 +749,9 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
748749
@ContentChildren(IgxSuffixDirective, { descendants: true })
749750
protected suffixes: QueryList<IgxSuffixDirective>;
750751

752+
@ViewChildren(IgxSuffixDirective)
753+
protected internalSuffixes: QueryList<IgxSuffixDirective>;
754+
751755
/** @hidden @internal */
752756
public get searchValue(): string {
753757
return this._searchValue;
@@ -984,8 +988,15 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
984988
this.inputGroup.prefixes = this.prefixes;
985989
}
986990

987-
if (this.inputGroup && this.suffixes?.length > 0) {
988-
this.inputGroup.suffixes = this.suffixes;
991+
if (this.inputGroup) {
992+
const suffixesArray = this.suffixes?.toArray() ?? [];
993+
const internalSuffixesArray = this.internalSuffixes?.toArray() ?? [];
994+
const mergedSuffixes = new QueryList<IgxSuffixDirective>();
995+
mergedSuffixes.reset([
996+
...suffixesArray,
997+
...internalSuffixesArray
998+
]);
999+
this.inputGroup.suffixes = mergedSuffixes;
9891000
}
9901001
}
9911002

projects/igniteui-angular/src/lib/input-group/input-group.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export class IgxInputGroupComponent implements IgxInputGroupBase {
291291
}
292292

293293
/** @hidden @internal */
294-
public set suffixes(items: QueryList<IgxPrefixDirective>) {
294+
public set suffixes(items: QueryList<IgxSuffixDirective>) {
295295
this._suffixes = items;
296296
}
297297

projects/igniteui-angular/src/lib/select/select.component.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
QueryList,
2323
TemplateRef,
2424
ViewChild,
25+
ViewChildren,
2526
ViewEncapsulation
2627
} from '@angular/core';
2728
import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
@@ -120,6 +121,9 @@ export class IgxSelectComponent extends IgxDropDownComponent implements IgxSelec
120121
@ContentChildren(IgxSuffixDirective, { descendants: true })
121122
protected suffixes: QueryList<IgxSuffixDirective>;
122123

124+
@ViewChildren(IgxSuffixDirective)
125+
protected internalSuffixes: QueryList<IgxSuffixDirective>;
126+
123127
/** @hidden @internal */
124128
@ContentChild(forwardRef(() => IgxLabelDirective), { static: true }) public label: IgxLabelDirective;
125129

@@ -542,8 +546,15 @@ export class IgxSelectComponent extends IgxDropDownComponent implements IgxSelec
542546
this.inputGroup.prefixes = this.prefixes;
543547
}
544548

545-
if (this.inputGroup && this.suffixes?.length > 0) {
546-
this.inputGroup.suffixes = this.suffixes;
549+
if (this.inputGroup) {
550+
const suffixesArray = this.suffixes?.toArray() ?? [];
551+
const internalSuffixesArray = this.internalSuffixes?.toArray() ?? [];
552+
const mergedSuffixes = new QueryList<IgxSuffixDirective>();
553+
mergedSuffixes.reset([
554+
...suffixesArray,
555+
...internalSuffixesArray
556+
]);
557+
this.inputGroup.suffixes = mergedSuffixes;
547558
}
548559
}
549560

src/app/input-group-showcase/input-group-showcase.sample.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class InputGroupShowcaseSampleComponent {
133133
}
134134
},
135135
hideSuffix: {
136-
label: 'Hide Suffix using( [hidden] )',
136+
label: 'Hide Suffix',
137137
control: {
138138
type: 'boolean',
139139
defaultValue: false

0 commit comments

Comments
 (0)