Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(chips): fix $apply already in progress
Browse files Browse the repository at this point in the history
Fixes #2458. Fixes #2544. Closes #2591.
  • Loading branch information
ThomasBurleson committed Apr 28, 2015
1 parent 713b2d6 commit daf680f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/components/chips/js/chipDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ function MdChip($mdTheming) {
function compile(element, attr) {
element.append(DELETE_HINT_TEMPLATE);
return function postLink(scope, element, attr, ctrl) {
element.addClass('md-chip');
$mdTheming(element);

if (ctrl) angular.element(element[0].querySelector('.md-chip-content'))
.on('blur', function () {
ctrl.$scope.$apply(function () { ctrl.selectedChip = -1; });

This comment has been minimized.

Copy link
@gkalpak

gkalpak Apr 29, 2015

Member

So who triggers the digest then ?

ctrl.selectedChip = -1;
});
element.addClass('md-chip');
$mdTheming(element);
};
}
}
10 changes: 6 additions & 4 deletions src/components/chips/js/chipsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,22 @@ MdChipsCtrl.prototype.configureUserInput = function(inputElement) {
inputElement
.attr({ tabindex: 0 })
.on('keydown', function(event) { scope.$apply(function() { ctrl.inputKeydown(event); }); })
.on('focus', function () { this.$scope.$apply(this.onInputFocus.bind(this)); }.bind(this))
.on('blur', function () { this.$scope.$apply(this.onInputBlur.bind(this)); }.bind(this));
.on('focus', ctrl.onInputFocus.bind(ctrl) )
.on('blur', ctrl.onInputBlur.bind(ctrl) );
};

MdChipsCtrl.prototype.configureAutocomplete = function(ctrl) {

ctrl.registerSelectedItemWatcher(function (item) {
if (item) {
this.appendChip(item);
this.resetChipBuffer();
}
}.bind(this));

this.$element.find('input')
.on('focus', function () { this.$scope.$apply(this.onInputFocus.bind(this)); }.bind(this))
.on('blur', function () { this.$scope.$apply(this.onInputBlur.bind(this)); }.bind(this));
.on('focus',this.onInputFocus.bind(this) )
.on('blur', this.onInputBlur.bind(this) );
};

MdChipsCtrl.prototype.hasFocus = function () {
Expand Down

0 comments on commit daf680f

Please sign in to comment.