Skip to content

Commit a006b22

Browse files
author
Angela Nicholas
committed
clear buffer when shifting characters to the left
1 parent 0b2f909 commit a006b22

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

spec/Focus.Spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,23 @@ feature("Leaving A Masked Input",function(){
126126
expect(input).toHaveValue("1_");
127127
});
128128
});
129+
130+
scenario("Shifts characters left on blur with autoclear false",function(){
131+
given("a mask with 10 placeholders",function(){
132+
input.mask("(999) 999-9999", { autoclear: false });
133+
});
134+
when("focusing input",function(){
135+
input.focus();
136+
});
137+
waits(20);
138+
when("typing characters at the end of the mask and blurring",function(){
139+
input.caret(12);
140+
input.mashKeys("44").blur();
141+
});
142+
then("characters should shift left to beginning of mask",function(){
143+
expect(input).toHaveValue("(44_) ___-____");
144+
});
145+
});
129146
});
130147

131148
feature("Optional marker",function(){

src/jquery.maskedinput.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ $.fn.extend({
305305
}
306306
}
307307
if (pos > test.length) {
308+
clearBuffer(i + 1, len);
308309
break;
309310
}
310311
} else if (buffer[i] === test.charAt(pos) && i !== partialPosition) {

0 commit comments

Comments
 (0)