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

fix(chips): interaction with Autocomplete #4108

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/chips/demoContactChips/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
md-contact-name="name"
md-contact-image="image"
md-contact-email="email"
md-require-match
md-require-match="true"
filter-selected="ctrl.filterSelected"
placeholder="To">
</md-contact-chips>
Expand Down
2 changes: 1 addition & 1 deletion src/components/chips/demoCustomInputs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2 class="md-title">Use an <code>input</code> element to build an ordered set
<br/>
<h2 class="md-title">Use <code>md-autocomplete</code> to build an ordered set of chips.</h2>

<md-chips ng-model="ctrl.selectedVegetables" md-autocomplete-snap md-require-match>
<md-chips ng-model="ctrl.selectedVegetables" md-autocomplete-snap md-require-match="true">
<md-autocomplete
md-selected-item="ctrl.selectedItem"
md-search-text="ctrl.searchText"
Expand Down
7 changes: 5 additions & 2 deletions src/components/chips/js/chipsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ function MdChipsCtrl ($scope, $mdConstant, $log, $element, $timeout) {
/** @type {number} */
this.selectedChip = -1;

/** @type {boolean} */
this.hasAutocomplete = false;


/**
* Hidden hint text for how to delete a chip. Used to give context to screen readers.
Expand Down Expand Up @@ -84,7 +87,7 @@ MdChipsCtrl.prototype.inputKeydown = function(event) {
var chipBuffer = this.getChipBuffer();
switch (event.keyCode) {
case this.$mdConstant.KEY_CODE.ENTER:
if (this.$scope.requireMatch || !chipBuffer) break;
if ((this.hasAutocomplete && this.requireMatch) || !chipBuffer) break;
event.preventDefault();
this.appendChip(chipBuffer);
this.resetChipBuffer();
Expand Down Expand Up @@ -343,7 +346,7 @@ MdChipsCtrl.prototype.configureUserInput = function(inputElement) {
};

MdChipsCtrl.prototype.configureAutocomplete = function(ctrl) {

this.hasAutocomplete = true;
ctrl.registerSelectedItemWatcher(angular.bind(this, function (item) {
if (item) {
this.appendChip(item);
Expand Down