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

Commit

Permalink
fix(chips): fixes issue where arrow keys switch active chip while edi…
Browse files Browse the repository at this point in the history
…ting input field
  • Loading branch information
Robert Messerle committed Apr 17, 2015
1 parent 4092400 commit 1f26144
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/components/chips/js/chipsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,18 @@
* @param event
*/
MdChipsCtrl.prototype.inputKeydown = function(event) {
var chipBuffer;
var chipBuffer = this.getChipBuffer();
switch (event.keyCode) {
case this.$mdConstant.KEY_CODE.ENTER:
if (this.$scope.requireMatch) break;
chipBuffer = this.getChipBuffer();
if (chipBuffer) {
event.preventDefault();
this.appendChip(chipBuffer);
this.resetChipBuffer();
}
if (this.$scope.requireMatch || !chipBuffer) break;
event.preventDefault();
this.appendChip(chipBuffer);
this.resetChipBuffer();
break;
case this.$mdConstant.KEY_CODE.BACKSPACE:
if (!event.target.value.length) {
event.stopPropagation();
if (this.items.length) this.selectAndFocusChipSafe(this.items.length - 1);
}
if (chipBuffer) break;
event.stopPropagation();
if (this.items.length) this.selectAndFocusChipSafe(this.items.length - 1);
break;
}
};
Expand All @@ -109,6 +105,7 @@
* @param event
*/
MdChipsCtrl.prototype.chipKeydown = function (event) {
if (this.getChipBuffer()) return;
switch (event.keyCode) {
case this.$mdConstant.KEY_CODE.BACKSPACE:
case this.$mdConstant.KEY_CODE.DELETE:
Expand Down

0 comments on commit 1f26144

Please sign in to comment.