-
-
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
Bugfix: keep filter status consistent with items updates #585
Conversation
src/ng-select/ng-select.component.ts
Outdated
if (this._isTypeahead) { | ||
this.typeahead.next(this.filterValue); | ||
} else if(this.isOpen) { | ||
this.itemsList.filter(this.filterValue); |
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.
This is the real bugfix regarding our use cases.
src/ng-select/ng-select.component.ts
Outdated
@@ -483,7 +483,11 @@ export class NgSelectComponent implements OnDestroy, OnChanges, AfterViewInit, C | |||
if (items.length > 0 && this.hasValue) { | |||
this.itemsList.mapSelectedItems(); | |||
} | |||
|
|||
if (this._isTypeahead) { | |||
this.typeahead.next(this.filterValue); |
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.
Not sure, if this is required.
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.
Yep, it is not needed.
src/ng-select/ng-select.component.ts
Outdated
|
||
if (this._isTypeahead) { | ||
this.typeahead.next(this.filterValue); | ||
} else if (this.isOpen) { |
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.
Thanks for contributing. In this case typeahead is not needed so you need to check it also you need to check if filterValue was actually set.
if (this.isOpen && isDefined(this.filterValue) && !this._isTypeahead) {
this.itemsList.filter(this.filterValue);
}
PS. Add unit test for this case when dropdown is opened and filter value is set. Thanks.
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.
Thanks for the review. I will get back to you ASAP.
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.
Great, thanks 👍
Do you plan to add that fix for 1.x version? |
Item list updates result in a reset of the filtered item list. This will result in an inconsistent state in case the ng-select is open while item list updates arrive.
This PR corrects the problem.