-
-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group by #317
Conversation
closes #263 |
|
||
.ng-dropdown-panel-items { | ||
.ng-optgroup { | ||
user-select: none; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep same height and padding for group
line-height: 3em;
height: 3em;
padding: 0 16px;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/themes/material.theme.scss
Outdated
color: rgba(0, 0, 0, 0.38); | ||
} | ||
&.ng-option-child { | ||
padding-left: 18px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and set double the padding for child
padding-left: 32px;
src/ng-select/items-list.ts
Outdated
|
||
private _groupBy(items: NgOption[], prop: string | Function): { [index: string]: NgOption[] } { | ||
const groups = items.reduce((grouped, item) => { | ||
const key = prop instanceof Function ? prop.apply(this, [item]) : item.value[prop]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can prop be a function in our case?
src/ng-select/items-list.ts
Outdated
} | ||
|
||
this._filteredItems = []; | ||
term = searchHelper.stripSpecialChars(term).toUpperCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as I have looked, toLowerCase
is much faster.
https://jsperf.com/javascript-touppercase-vs-tolowercase/2
src/ng-select/items-list.ts
Outdated
|
||
this._filteredItems = []; | ||
term = searchHelper.stripSpecialChars(term).toUpperCase(); | ||
for (const key of Object.keys(this._groups)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this can be simplified firstly filtering on flat structure items that match term:
this._filteredItems = this.items.filter(item => {
const label = searchHelper.stripSpecialChars(item.label ? item.label.toString() : '').toLowerCase();
return item.hasChildren || label.indexOf(term) > -1;
})
and then removing all groups that have no children?
Ideally it would be only two iterations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this version, but it is significant slower. In example with 5000 items there each item has one group(slowest possible scenario) I got result of 320ms for every filter call. This is because in second loop you will need check for each parent item if it has child items. Current implementation took only 13ms to complete. This is because you just need to search ones in each group and then only find head item and push it as first in group, also I'm not searching in group head items which is not needed.
No description provided.