-
Notifications
You must be signed in to change notification settings - Fork 914
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
options not filtered correctly when using ngOptionHighlight #1244
Comments
I spent some time this morning to find source of this problem and I believe the cause lies in new trackByFn for dropdown options: The list of options in dropdown is actually filtered correctly, and it is always cut down to correct number of options. You can even click a "wrong" option, and it turns out it's actually a correct one underneath. The only thing that doesn't work properly is displaying option labels in rendered HTML. The current trackByOption looks like this:
If you do not supply your own trackByFn, it will return null for all options by default. I believe this means that Angular won't detect changes between swapped options and will see no need to re-render them, causing the problem. I think the default implementation should just return the whole item, so it can always compare object identity. We can workaround this bug in current version by supplying our own trackByFn to ng-select component:
Some other issues that I believe concern this bug: |
@LKU4 you are right, it was a bad idea to return null by default |
This still does not work for me in v3.0.1. Only by providing own |
it does work in demo page |
Please fill below information if issuing a bug report.
Expected behaviour
options in the dropdown should filter according to search term
Actual behaviour
the options are not filtered correctly (see your example page https://ng-select.github.io/ng-select#/forms the last example)
More Info
ng-select version: 2.20.3
browser: [INSERT BROWSER INFO HERE]
reproducible in demo page: YES
The text was updated successfully, but these errors were encountered: