-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editing in the middle of the string #4
Comments
I was just discussion this. Usually people miss one character, not several, so the going to the end is by design. My original version has caret placement memory - i don't think i committed that. I guess I could add that back in as an option. |
@estelle I think that would be a great option to add so that those that want it can enable it. |
plz implement this option |
Definitely not the best solution. More quick'n'dirty ;-) handleValueChange : function (e) {
var id = e.target.getAttribute('id');
var cursorPosBefore = e.target.selectionStart;
var cursorPosAfter = e.target.selectionStart;
if(e.target.value == document.querySelector('#' + id + 'Mask i').innerHTML) {
return; // Continue only if value hasn't changed
}
document.getElementById(id).value = this.handleCurrentValue(e);
document.getElementById(id + 'Mask').innerHTML = this.setValueOfMask(e);
cursorPosAfter = e.target.selectionStart; // update cursor pos
// when cursor is jumping over spaces
if (cursorPosAfter - cursorPosBefore > 1 ) {
document.getElementById(id).selectionStart = cursorPosBefore;
document.getElementById(id).selectionEnd = cursorPosBefore;
}
}, |
I would say this is not an enhancement BUT a violation of a WCAG principle - WCAG SC 3.2.2: On Input (Level A) --- Moving a user's focus can be especially jarring and it happens as soon as an element gets deleted in the middle of the string. -- |
I lied, I found one more issue that I see common to many input maskers :)
Let's say I enter a 16 digit credit card. Now I realize I messed up the second set of four numbers and need to edit them. I highlight that set, start typing, the first number gets replaced and the carat jumps to the end of the set and I'm now editing character 14. I'd expect that I can continue editing in place at character 5.
The text was updated successfully, but these errors were encountered: