javascriptangularjsangular-materialmd-autocompletemd-chip

Angular Material - Autocomplete doesn't show suggestions when md-chips are closed


md-autocomplete doesn't show listed suggestions when the chips are closed, for varying list of suggestions.

Scenario: I want to show suggestions only for the chips that are not added. Initially, all the chips are added, so there are no more chips left to add - no suggestions, which is fine. When a chip is closed and the input field is focused, there are still no suggestions but ideally there should be one chip in the suggestions list. The suggestions appear only if one or more characters are typed in.

md-autocomplete should re-render the items even when the query string length is 0, but seems like it is set to 1. This can be inferred by observing the filter function defined in md-items which doesn't get triggered, when the query string is empty.

Here is the CodePen link

Delete the added chips and focus on the input field. Observe that no suggestions for the closed chips are being displayed by md-autocomplete.


Solution

  • This is a bug with Angular Material library. I have raised an issue on Angular Material Github repo. A fix has been committed and is under review. Most probably, the patch should be available in the next release. Here is the link to the issue.