Skip to content

Commit

Permalink
fix: use width for dropdown panel
Browse files Browse the repository at this point in the history
varnastadeus committed Apr 24, 2018

Verified

This commit was signed with the committer’s verified signature.
Julesssss Jules
1 parent a39ca01 commit c07351c
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/ng-select/items-list.ts
Original file line number Diff line number Diff line change
@@ -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) ? (<Function>prop).apply(this, [item.value]) : item.value[<string>prop];
const key = isFn ? (<Function>prop).apply(this, [item.value]) : item.value[<string>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++;
3 changes: 1 addition & 2 deletions src/ng-select/ng-dropdown-panel.component.ts
Original file line number Diff line number Diff line change
@@ -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<void> {

0 comments on commit c07351c

Please sign in to comment.