angular / material

Material design for AngularJS
https://material.angularjs.org/
MIT License
16.55k stars 3.39k forks source link

autocomplete(perf): each keypress fires 3 $digests (shift, alt, ctrl key fires infinitely) #10744

Open Nickproger opened 7 years ago

Nickproger commented 7 years ago

Actual Behavior:

CodePen (or steps to reproduce the issue): https://codepen.io/anon/pen/yXVwRa?editors=1010

AngularJS Versions: *

Additional Information:


Shortcut to create a new CodePen Demo. Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

henrymana commented 7 years ago

I haven't tried the md-delay option but looking at the documentation it seems it may work for you.

https://material.angularjs.org/latest/api/directive/mdAutocomplete

md-delay: "Specifies the amount of time (in milliseconds) to wait before looking for results"

Could you please close the issue as question answered :-) if this works for you?

Nickproger commented 7 years ago

@henrymana, Unfortunately it doesn't help.. as i understand it just postpone calling handler for getting matched items. In my opinion it would be good for performnce if md-autocomplete didn't fire any $digests at all until md-delay fires handler. It seems md-autocomplete should be rewritten in more 'vanilla-js' (not-angular) way or use ng-model-options with debounce inside. And if so then after this PR https://github.com/angular/angular.js/pull/16064 will be merged this issue could be fix automatically... (without this PR will have 1 $digest per key instead of 3)