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

Unexpected "focus"/"blur" handling for md-chips containing md-autocomplete #3357

Closed
stephenwan opened this issue Jun 19, 2015 · 1 comment
Closed

Comments

@stephenwan
Copy link

The issue exists in the latest release (v0.10.0) and previous releases ( < 0.9.x). It can be seen on the demo page of the ng-material website (https://material.angularjs.org/latest/#/demo/material.components.chips).

Symptom

  1. Goto the example for Use md-autocomplete to build an ordered set of chips. under the Custom Inputs section in Demo for Chips.
  2. Focus the input element by clicking it.
  3. Expect to see the input element with blue underline. But no blue underline is shown.
  4. Click somewhere else to blur the input.
  5. Expected to see no blue underline, but blue underline is shown.

Possible cause

The code below is from chipsController.js

MdChipsCtrl.prototype.configureAutocomplete = function(ctrl) {
  ctrl.registerSelectedItemWatcher(angular.bind(this, function (item) {
    if (item) {
      this.appendChip(item);
      this.resetChipBuffer();
    }
  }));
  this.$element.find('input')
      .on('focus',angular.bind(this, this.onInputFocus) )
      .on('blur', angular.bind(this, this.onInputBlur) );
};

I suspect the callbacks for focus and blur are invoked outside angular's digest loop. Some scope.$apply() thing should be used here.

On the other hand, md-input has the correct behavior because its callbacks are registered through ng-focus and ng-blur inside the template instead of manually setting up the event listeners.

@marcysutton
Copy link
Contributor

This is a duplicate of #2607.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants