Skip to content

Commit 59e2004

Browse files
committed
Allow cmd/ctrl actions to execute (even when control is full) - except for pasting. Fixes #146.
1 parent 75569c0 commit 59e2004

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/selectize.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ $.extend(Selectize.prototype, {
164164
keypress : function() { return self.onKeyPress.apply(self, arguments); },
165165
resize : function() { self.positionDropdown.apply(self, []); },
166166
blur : function() { return self.onBlur.apply(self, arguments); },
167-
focus : function() { return self.onFocus.apply(self, arguments); }
167+
focus : function() { return self.onFocus.apply(self, arguments); },
168+
paste : function() { return self.onPaste.apply(self, arguments); }
168169
});
169170

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

365+
366+
/**
367+
* Triggered on <input> paste.
368+
*
369+
* @param {object} e
370+
* @returns {boolean}
371+
*/
372+
onPaste: function(e) {
373+
var self = this;
374+
if (self.isFull() || self.isInputHidden || self.isLocked) {
375+
e.preventDefault();
376+
}
377+
},
378+
364379
/**
365380
* Triggered on <input> keypress.
366381
*
@@ -451,7 +466,8 @@ $.extend(Selectize.prototype, {
451466
self.deleteSelection(e);
452467
return;
453468
}
454-
if (self.isFull() || self.isInputHidden) {
469+
470+
if ((self.isFull() || self.isInputHidden) && !(IS_MAC ? e.metaKey : e.ctrlKey)) {
455471
e.preventDefault();
456472
return;
457473
}

0 commit comments

Comments
 (0)