-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Caret Positiong on Android #464
Conversation
I tried to recover the old function "setCaret" in order to get rid of the caret positioning problem on android devices. I tested this modification on my Samsung Galaxy Note3 8" running Android 4.4.2 (KitKat) and it's ok so far.
fix on setCaret for android devices
I've tested this on some samsung devices and it seems to fix it... |
@fernandobandeira take a look into this comment: #432 (comment) |
@igorescobar He's right, you can check it on desktop: http://mask.artistas.io/ But with this one we'll fix the mobile issue... You can check this other mask I think that we should merge this and then start working on a fix for this issue, this is already broken anyway... |
@fernandobandeira you are right. I'm need to spend some time and try to fix this. Lots happening on my work right now its been hard to find some spear time and get this done. |
Turned out that this doesn't fixed the problem. I released a fix for this at: Could you all test it please? |
Check the video: https://drive.google.com/file/d/0B5j7CzpTIt5BTmtpVmdLTjh2bVE/view?usp=sharing Tested just now (less than 10 minutes) on http://igorescobar.github.io/jQuery-Mask-Plugin/ Seems to be using the latest v1.14.3 😢 |
@fernandobandeira A few users with Android browser tested and said it is fine... thats weird... any idea on how I can reproduce this without having a freaking android phone? |
@igorescobar You need a samsung device using a samsung keyboard and the default browser, if you use chrome, or switftkey for example it will work fine. You can't test it on emulator because of that. Most of us as dev's mostly switch to chrome or use something like swiftkey but it doesn't mean that our users aren't affected by this... Maybe https://www.browserstack.com/ can simulate this, they use native phones instead of emulating so i guess you can reproduce this there, they also give free license to Open Source so you could try that, it would make your life easier =) This can be fixed, v1.13.9 for example works fine... |
@fernandobandeira yeah I've just tested on a friend's phone with chrome (default browser doesnt exist on his phone) and it worked fine. I need to reproduce on a place where I can debug, browser stack wouldnt help me. The Android "default browser" seems to have only 6% of the browser market as seen here: I will try to fix it but seems like a waste of time because the market share is going down each month. |
@fernandobandeira I've just tested on the Default Chrome browser on a friend's samsung and it also worked fine (Android Browser v4.0.10-53 I think). in which version are you testing it? |
I'm also using 4.0.10-53 on a note5, check if he's using the default samsung keyboard, this is an issue with autocomplete + this browser. I'm able to reproduce this on S6 and other phones as well... |
@fernandobandeira if you add |
Yes on mostly phones S6, note5 included, some of them like the J7 still have the issue so there's exceptions, the way v1.13.9 does seems to fix for these as well, not sure whats the real deal, seems more like an autocomplete bug that's changing how the caret function works. |
@fernandobandeira I could work around this: If this made it work. |
There's only 1 mask that I know that fixed this issue, here's the relevant commit: digitalBush/jquery.maskedinput@89aa9d3 They didn't release a version with this fix, it's over a year already digitalBush/jquery.maskedinput#280 and digitalBush/jquery.maskedinput#302 I've hosted a demo with the fix here: http://mask.artistas.io/demo/ Here's a video: https://drive.google.com/file/d/0B5j7CzpTIt5Bd0RSMVFTeHA5bWM/view?usp=sharing Notice how the caret moves to the end of the input after typing (123), but the input still goes in the right position, I guess that's the workaround. This PR does fix it too btw... |
@fernandobandeira That's weird... this PR fix this but what actually happens is that it also breaks caret positions in all webkit browsers. So it fixes it this but it also breaks for everybody else. What really happens is that the function The fact that this kinda works for this scenario is only a good surprise :P |
@fernandobandeira What you could do is... you can comment out this entire snippet and see if it works: If it works what we can do is to bypass caret positioning for this specific user agent. |
@igorescobar Yes it works when we bypass the caret positioning, https://drive.google.com/file/d/0B5j7CzpTIt5BOUVyZVpGcDNjaEE/view?usp=sharing I think we can fix it with this |
@fernandobandeira Cool! Can you inform the the full user agent? What happens if you erase something in the middle and try to type a new thing? like you erase the month and tries to type something else inside it? |
Full user agent
I think that matching indexOf And as you probably thought when erasing something and typing again things get messy, everytime you delete/type something the caret moves to the end of the input so if you have 12/10/1990 you delete 12/10/1990, it will turn into 12/01/990 | |
@fernandobandeira that's what I thought because the cursor goes to the end and things will get messy indeed. Oh boy I wanted so badly do debug this and fix this properly LOL. |
And hey! @fernandobandeira thank you so much for your help and your videos... VERY helpful! |
I just downloaded and i'm still having the same problem on Samsung S6 and Samsung S6 Edge. To make it work i'm using the following workaround with the onChange callback (not pretty at all but it works). Hope it helps. $('section.inscricao #cpf').mask('000.000.000-00',
{
reverse: true,
onChange: function(cpf){
var cpfEl = $('section.inscricao #cpf').get(0);
cpfEl.selectionStart = cpfEl.selectionEnd = cpfEl.value.length;
}
}
); |
@labmorales could you test this version, please? |
@fernandobandeira I noticed that a guys seems to fix this by just adding a setTimeout interval before setting the caret position so I changed his code a liitle bit to make it fit on our architecture. I removed the |
@igorescobar tested this new version, still having problem (Moto G3 - Chrome). I've recorded the problem: https://youtu.be/dknWyxhxtGE (trying to type 21/12/2016) |
@felipejunges @fernandobandeira Could you please give it a try? |
@igorescobar unfortunately the behavior stills (the cursor come "back" right after the "/" char) |
@felipejunges by any change we could talk via Skype? |
Sure, sent you the invite (BTW, I'm brazilian too!) |
many thanks to @felipejunges and @fernandobandeira the new version is released. |
@labmorales @diebugger @schmidt @fernandobandeira upgrade your version. Let me know if its okay now. |
Worked for me on both samsung browser and chrome, tested on https://igorescobar.github.io/jQuery-Mask-Plugin/ with the v1.14.8 😄, ps sry for the delay... |
Awesome @fernandobandeira thanks! |
Samsung Galaxy s IV mini SCH-1435 still has the issue.When we have a number format with 123-456. My input is 123 and upon typing 4 the caret position is retained next to hyphen and data entered is moving to last position |
recovered setCaret from version 1.13.9 (avoid issues on android devices)