Skip to content

Commit c07351c

Browse files
committed
fix: use width for dropdown panel
1 parent a39ca01 commit c07351c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/ng-select/items-list.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,9 @@ export class ItemsList {
268268
}
269269

270270
private _groupBy(items: NgOption[], prop: string | Function): OptionGroups {
271+
const isFn = isFunction(this._ngSelect.groupBy);
271272
const groups = items.reduce((grouped, item) => {
272-
const key = isFunction(prop) ? (<Function>prop).apply(this, [item.value]) : item.value[<string>prop];
273+
const key = isFn ? (<Function>prop).apply(this, [item.value]) : item.value[<string>prop];
273274
const group = grouped.get(key);
274275
if (group) {
275276
group.push(item);
@@ -282,6 +283,7 @@ export class ItemsList {
282283
}
283284

284285
private _flatten(groups: OptionGroups) {
286+
const isFn = isFunction(this._ngSelect.groupBy);
285287
let i = 0;
286288

287289
return Array.from(groups.keys()).reduce((items: NgOption[], key: string) => {
@@ -292,7 +294,7 @@ export class ItemsList {
292294
disabled: !this._ngSelect.selectableGroup,
293295
htmlId: newId()
294296
};
295-
const groupKey = isFunction(this._ngSelect.groupBy) ? this._ngSelect.bindLabel : this._ngSelect.groupBy;
297+
const groupKey = isFn ? this._ngSelect.bindLabel : this._ngSelect.groupBy;
296298
parent.value = { [groupKey]: key };
297299
items.push(parent);
298300
i++;

src/ng-select/ng-dropdown-panel.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ export class NgDropdownPanelComponent implements OnInit, OnChanges, OnDestroy, A
340340
dropdownPanel.style.top = offsetTop + topDelta + 'px';
341341
dropdownPanel.style.bottom = 'auto';
342342
dropdownPanel.style.left = offsetLeft + 'px';
343-
dropdownPanel.style.minWidth = selectRect.width + 'px';
344-
dropdownPanel.style.width = 'auto';
343+
dropdownPanel.style.width = selectRect.width + 'px';
345344
}
346345

347346
private _whenContentReady(): Promise<void> {

0 commit comments

Comments
 (0)