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

Commit

Permalink
update(chips): deletion can now only occur when the input is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Messerle committed Apr 15, 2015
1 parent 1e38b83 commit bde2463
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/components/chips/js/chipsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,13 @@
}
break;
case this.$mdConstant.KEY_CODE.BACKSPACE:
if (shouldDeletePreviousItem(event.target)) {
if (!event.target.value.length) {
event.preventDefault();
if (this.items.length) this.removeChip(this.items.length - 1);
event.target.focus();
}
break;
}
function shouldDeletePreviousItem (element) {
if ((/text|password|search|tel|url/).test(element.type)) {
return !element.selectionStart && !element.selectionEnd;
} else {
return !element.value.length;
}
}
};

/**
Expand Down

0 comments on commit bde2463

Please sign in to comment.