Skip to content

Commit 196a818

Browse files
committed
Disallow caret advancement when textbox has value.
1 parent 18fe22b commit 196a818

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

jquery.selectize.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,11 +1515,12 @@
15151515
var selection = getSelection(this.$control_input[0]);
15161516

15171517
if (this.isInputFocused) {
1518+
var valueLength = this.$control_input.val().length;
15181519
var cursorAtEdge = direction < 0
15191520
? selection.start === 0 && selection.length === 0
1520-
: selection.start === this.$control_input.val().length;
1521+
: selection.start === valueLength;
15211522

1522-
if (cursorAtEdge) {
1523+
if (cursorAtEdge && !valueLength) {
15231524
this.advanceCaret(direction, e);
15241525
}
15251526
} else {

jquery.selectize.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/selectize.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,11 +1148,12 @@ Selectize.prototype.advanceSelection = function(direction, e) {
11481148
var selection = getSelection(this.$control_input[0]);
11491149

11501150
if (this.isInputFocused) {
1151+
var valueLength = this.$control_input.val().length;
11511152
var cursorAtEdge = direction < 0
11521153
? selection.start === 0 && selection.length === 0
1153-
: selection.start === this.$control_input.val().length;
1154+
: selection.start === valueLength;
11541155

1155-
if (cursorAtEdge) {
1156+
if (cursorAtEdge && !valueLength) {
11561157
this.advanceCaret(direction, e);
11571158
}
11581159
} else {

0 commit comments

Comments
 (0)