diff --git a/src/ng-select/items-list.ts b/src/ng-select/items-list.ts index 88d932be7..c79149865 100644 --- a/src/ng-select/items-list.ts +++ b/src/ng-select/items-list.ts @@ -268,8 +268,9 @@ export class ItemsList { } private _groupBy(items: NgOption[], prop: string | Function): OptionGroups { + const isFn = isFunction(this._ngSelect.groupBy); const groups = items.reduce((grouped, item) => { - const key = isFunction(prop) ? (prop).apply(this, [item.value]) : item.value[prop]; + const key = isFn ? (prop).apply(this, [item.value]) : item.value[prop]; const group = grouped.get(key); if (group) { group.push(item); @@ -282,6 +283,7 @@ export class ItemsList { } private _flatten(groups: OptionGroups) { + const isFn = isFunction(this._ngSelect.groupBy); let i = 0; return Array.from(groups.keys()).reduce((items: NgOption[], key: string) => { @@ -292,7 +294,7 @@ export class ItemsList { disabled: !this._ngSelect.selectableGroup, htmlId: newId() }; - const groupKey = isFunction(this._ngSelect.groupBy) ? this._ngSelect.bindLabel : this._ngSelect.groupBy; + const groupKey = isFn ? this._ngSelect.bindLabel : this._ngSelect.groupBy; parent.value = { [groupKey]: key }; items.push(parent); i++; diff --git a/src/ng-select/ng-dropdown-panel.component.ts b/src/ng-select/ng-dropdown-panel.component.ts index f0ef3fde0..cadc60c86 100644 --- a/src/ng-select/ng-dropdown-panel.component.ts +++ b/src/ng-select/ng-dropdown-panel.component.ts @@ -340,8 +340,7 @@ export class NgDropdownPanelComponent implements OnInit, OnChanges, OnDestroy, A dropdownPanel.style.top = offsetTop + topDelta + 'px'; dropdownPanel.style.bottom = 'auto'; dropdownPanel.style.left = offsetLeft + 'px'; - dropdownPanel.style.minWidth = selectRect.width + 'px'; - dropdownPanel.style.width = 'auto'; + dropdownPanel.style.width = selectRect.width + 'px'; } private _whenContentReady(): Promise {