Skip to content

Commit 6113c83

Browse files
committed
fix(suggest): condition title display by input
1 parent 63e160d commit 6113c83

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

projects/angular/components/ui-suggest/src/ui-suggest.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<ng-template #showDefaultValue>
4545
<div [matTooltip]="tooltip ?? ''"
4646
class="display-container text-ellipsis">
47-
<span *ngIf="!isFormControl && placeholder"
47+
<span *ngIf="!isFormControl && placeholder && !shouldHideTitle"
4848
class="display-title"
4949
aria-hidden="true">
5050
{{ placeholder }}:

projects/angular/components/ui-suggest/src/ui-suggest.component.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class UiSuggestFixtureDirective {
8989
displayPriority: 'default' | 'selected' = 'default';
9090
fetchStrategy: 'eager' | 'onOpen' = 'eager';
9191
minChars = 0;
92+
shouldHideTitle = false;
9293

9394
set value(value: ISuggestValue[] | undefined) {
9495
this._value = value;
@@ -148,6 +149,21 @@ const sharedSpecifications = (
148149
});
149150

150151
describe('Behavior: standard usage', () => {
152+
([true, false].forEach(shouldHideTitle => {
153+
it(`should ${shouldHideTitle ? 'not' : ''} display title if shouldHideTitle is ${shouldHideTitle}`, () => {
154+
component.placeholder = 'some place holder';
155+
component.shouldHideTitle = shouldHideTitle;
156+
157+
fixture.detectChanges();
158+
const spanElem = document.querySelector('.display-title');
159+
if (shouldHideTitle || uiSuggest.isFormControl) {
160+
expect(spanElem).toBeNull();
161+
} else {
162+
expect(spanElem).toBeTruthy();
163+
}
164+
});
165+
}));
166+
151167
it('should be initialized', () => {
152168
expect(uiSuggest).toBeDefined();
153169
});
@@ -2464,7 +2480,8 @@ describe('Component: UiSuggest', () => {
24642480
[minChars]="minChars"
24652481
[drillDown]="drillDown"
24662482
[readonly]="readonly"
2467-
[compact]="compact">
2483+
[compact]="compact"
2484+
[shouldHideTitle]="shouldHideTitle">
24682485
</ui-suggest>
24692486
`,
24702487
})

projects/angular/components/ui-suggest/src/ui-suggest.mat-form-field.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ export abstract class UiSuggestMatFormFieldDirective implements
103103
this.stateChanges.next();
104104
}
105105

106+
/**
107+
* Hides the combo box title.
108+
*
109+
*/
110+
@Input()
111+
shouldHideTitle = false;
112+
106113
/**
107114
* Set a custom size for the list items.
108115
*

0 commit comments

Comments
 (0)