Skip to content
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

Merged
merged 2 commits into from
May 29, 2018
Merged

Bugfix: keep filter status consistent with items updates #585

merged 2 commits into from
May 29, 2018

Conversation

coreprocess
Copy link
Contributor

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.

@coveralls
Copy link

coveralls commented May 26, 2018

Coverage Status

Coverage increased (+0.8%) to 94.098% when pulling ca14074 on core-process:master into 291682d on ng-select:master.

if (this._isTypeahead) {
this.typeahead.next(this.filterValue);
} else if(this.isOpen) {
this.itemsList.filter(this.filterValue);
Copy link
Contributor Author

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.

@@ -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);
Copy link
Contributor Author

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.

Copy link
Member

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.


if (this._isTypeahead) {
this.typeahead.next(this.filterValue);
} else if (this.isOpen) {
Copy link
Member

@anjmao anjmao May 28, 2018

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks 👍

@anjmao anjmao merged commit 5eecd83 into ng-select:master May 29, 2018
@AlexTrashkov
Copy link

Do you plan to add that fix for 1.x version?

jakemdunn pushed a commit to jakemdunn/ng-select that referenced this pull request Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants