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

fixes #37 render chips on commas #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 dist/angular-chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
/*@ngInject*/
function ChipControlLinkFun(scope, iElement, iAttrs, chipsCtrl) {
iElement.on('keypress', function(event) {
if (event.keyCode === 13) {
if (event.keyCode === 13 || event.keyCode === 44) {
if (event.target.value !== '' && chipsCtrl.addChip(event.target.value)) {
event.target.value = "";
}
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-chips.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/js/directives/controls/chip_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/*@ngInject*/
function ChipControlLinkFun(scope, iElement, iAttrs, chipsCtrl) {
iElement.on('keypress', function(event) {
if (event.keyCode === 13) {
if (event.keyCode === 13 || event.keyCode === 44) {
if (event.target.value !== '' && chipsCtrl.addChip(event.target.value)) {
event.target.value = "";
}
Expand Down
9 changes: 9 additions & 0 deletions test/basic_flow_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ describe('Directive chips : Basic flow', function() {
expect(scope.samples[scope.samples.length-1]).toBe('Spain');
});

it('pressing Comma key (,) on INPUT element should add the chip',function(){
var inputEle = element.find('INPUT')[0];
inputEle.value = 'Italy';
var event = new Event('keypress');
event.keyCode = 44;
inputEle.dispatchEvent(event);
expect(scope.samples[scope.samples.length-1]).toBe('Italy');
});

it('check deleting chip by passing string', function() {
isolateScope.chips.deleteChip(scope.samples.indexOf('Pramati'));
expect(scope.samples.indexOf('Pramati')).toBe(-1);
Expand Down