Skip to content

Commit

Permalink
Allow cmd/ctrl actions to execute (even when control is full) - excep…
Browse files Browse the repository at this point in the history
…t for pasting. Fixes #146.
  • Loading branch information
brianreavis committed Apr 30, 2014
1 parent 75569c0 commit 59e2004
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ $.extend(Selectize.prototype, {
keypress : function() { return self.onKeyPress.apply(self, arguments); },
resize : function() { self.positionDropdown.apply(self, []); },
blur : function() { return self.onBlur.apply(self, arguments); },
focus : function() { return self.onFocus.apply(self, arguments); }
focus : function() { return self.onFocus.apply(self, arguments); },
paste : function() { return self.onPaste.apply(self, arguments); }
});

$document.on('keydown' + eventNS, function(e) {
Expand Down Expand Up @@ -361,6 +362,20 @@ $.extend(Selectize.prototype, {
this.$input.trigger('change');
},


/**
* Triggered on <input> paste.
*
* @param {object} e
* @returns {boolean}
*/
onPaste: function(e) {
var self = this;
if (self.isFull() || self.isInputHidden || self.isLocked) {
e.preventDefault();
}
},

/**
* Triggered on <input> keypress.
*
Expand Down Expand Up @@ -451,7 +466,8 @@ $.extend(Selectize.prototype, {
self.deleteSelection(e);
return;
}
if (self.isFull() || self.isInputHidden) {

if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
e.preventDefault();
return;
}
Expand Down

0 comments on commit 59e2004

Please sign in to comment.