li.setAttribute('display', 0);
li.setAttribute('selected', '');
- this.closeDropdown(sb, true);
+ this.closeDropdown(sb);
}
this.saveValues(sb, ul);
if (this.options.multiple)
this.transformItem(sb, new_item);
+ if (!new_item.hasAttribute('unselectable'))
+ new_item.setAttribute('tabindex', 0);
+
return new_item;
},
var li = active.nextElementSibling;
this.setFocus(sb, li);
if (this.options.create && li == li.parentNode.lastElementChild) {
- var input = li.querySelector('input');
+ var input = li.querySelector('input:not([type="hidden"]):not([type="checkbox"]');
if (input) input.focus();
}
ev.preventDefault();
if (input.classList.contains('cbi-input-invalid'))
return;
+ this.handleCreateBlur(ev);
this.createItems(sb, input.value);
input.value = '';
- input.blur();
+ break;
+
+ case 27:
+ this.handleCreateBlur(ev);
+ this.closeDropdown(sb);
+ ev.stopPropagation();
+ input.value = '';
break;
case 38: