Skip to content

Commit 0808f5e

Browse files
committed
refactor(combobox): returned combobox to use T instead of T or T[].
1 parent 32d7bdb commit 0808f5e

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/cdk-experimental/combobox/combobox-panel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {Subject} from 'rxjs';
1717
})
1818
export class CdkComboboxPanel<T = unknown> {
1919

20-
valueUpdated: Subject<T | T[]> = new Subject<T | T[]>();
20+
valueUpdated: Subject<T> = new Subject<T>();
2121
contentIdUpdated: Subject<string> = new Subject<string>();
2222
contentTypeUpdated: Subject<AriaHasPopupValue> = new Subject<AriaHasPopupValue>();
2323

@@ -26,8 +26,8 @@ export class CdkComboboxPanel<T = unknown> {
2626

2727
constructor(readonly _templateRef: TemplateRef<unknown>) {}
2828

29-
/** Tells the parent combobox to close the panel and sends back the content value. */
30-
closePanel(data?: T | T[]) {
29+
/** Tells the parent combobox to closet he panel and sends back the content value. */
30+
closePanel(data?: T) {
3131
this.valueUpdated.next(data);
3232
}
3333

src/cdk-experimental/combobox/combobox.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ describe('Combobox', () => {
8080
[openActions]="'focus'">
8181
No Value
8282
</button>
83+
8384
<ng-template cdkComboboxPanel #panel="cdkComboboxPanel">
8485
Panel Content
8586
</ng-template>`,

src/cdk-experimental/combobox/combobox.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class CdkCombobox<T = unknown> implements OnDestroy, AfterContentInit {
4949
private _panel: CdkComboboxPanel<T> | undefined;
5050

5151
@Input()
52-
value: T | T[];
52+
value: T;
5353

5454
@Input()
5555
get disabled(): boolean { return this._disabled; }
@@ -68,7 +68,7 @@ export class CdkCombobox<T = unknown> implements OnDestroy, AfterContentInit {
6868
@Output('comboboxPanelOpened') readonly opened: EventEmitter<void> = new EventEmitter<void>();
6969
@Output('comboboxPanelClosed') readonly closed: EventEmitter<void> = new EventEmitter<void>();
7070
@Output('panelValueChanged')
71-
readonly panelValueChanged: EventEmitter<T | T[]> = new EventEmitter<T | T[]>();
71+
readonly panelValueChanged: EventEmitter<T> = new EventEmitter<T>();
7272

7373
private _overlayRef: OverlayRef;
7474
private _panelContent: TemplatePortal;
@@ -137,7 +137,7 @@ export class CdkCombobox<T = unknown> implements OnDestroy, AfterContentInit {
137137
return !!this.panel;
138138
}
139139

140-
private _setComboboxValue(value: T | T[]) {
140+
private _setComboboxValue(value: T) {
141141
const valueChanged = (this.value !== value);
142142
this.value = value;
143143

@@ -147,14 +147,9 @@ export class CdkCombobox<T = unknown> implements OnDestroy, AfterContentInit {
147147
}
148148
}
149149

150-
private _setTextContent(content: T | T[]) {
150+
private _setTextContent(content: T) {
151151
const contentArray = coerceArray(content);
152-
const contentString = '';
153-
for (const token of contentArray) {
154-
contentString.concat(`${token} `);
155-
}
156-
157-
this._elementRef.nativeElement.textContent = contentString;
152+
this._elementRef.nativeElement.textContent = contentArray.join(' ');
158153
}
159154

160155
private _getOverlayConfig() {

0 commit comments

Comments
 (0)