material icon indicating copy to clipboard operation
material copied to clipboard

mdAutocomplete wrongly triggers md-selected-item-change

Open rscottfree opened this issue 11 years ago • 2 comments

This can be reproduced using the basic usage demo of md-autocomplete.

  1. Type in Ala into the input field
  2. Select Alabama (with keyboard or mouse)
  3. Focus should still be in input field. Type one more character.
  4. Issue: After typing this character the md-selected-item-change callback is called and in the console you see this:

Item changed to undefined

I would expect that only the md-search-text-change callback would be triggered.

Entering more characters does not trigger this, only the first character after selecting an item.

I don't think that the selected item should change just because another character changes in the input box.

If code in your md-search-text-change callback depends on what item was last selected then you run into problems because your selected item is now null.

This problem exists in 0.10.0 and 0.10.1 release candidates up to rc3

rscottfree avatar Jul 22 '15 21:07 rscottfree

This is as designed. When the search text no longer matches your selected item, the selected item is reset. This is necessary for a number of reasons.

robertmesserle avatar Sep 10 '15 17:09 robertmesserle

This makes it impossible to trigger a callback on the actual item selected though. I pretty much always get null/undefined when the callback is run and nothing happens when I select the item

simkessy avatar Jan 24 '16 07:01 simkessy