Skip to content
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

Android Information #465

Closed
rizowski opened this issue Mar 24, 2014 · 46 comments
Closed

Android Information #465

rizowski opened this issue Mar 24, 2014 · 46 comments
Labels
Milestone

Comments

@rizowski
Copy link

I have found some information that I hope is useful for Android. I have found that this library still breaks on Galaxy devices. I started to look into what was causing some of these issues. As of right now, Galaxy devices are not registering the keys that are pressed. It instead returns 0 for the keydown/up events. I have written several tests to see if I could replicate the issue and spent several days scratching my head to why they were passing when I could clearly break it.

The Jasmine tests that I have written are similar to yours but they are returning a false positive on input. As you can specify in code what key is pressed and so the mask is working if it receives a keycode. Although if it receives keycode 0 (null in Ascii) it does not know how to handle that and allows input before the mask no limit to the number of characters entered.

Here is some of the tests that I have used for trying to identify the problem. For these tests I was using your sendKey and sendKeys methods.

    beforeEach(function () {
        jasmine.getFixtures().set('<input type="tel" id="test"/>');
        inputField = $('#test');
    });
    describe("SSN", function () {
        var deleteInput = function () {
            for (var i = 0; i < inputField.val().length; i++) {
                inputField.sendKey(keys.BACKSPACE);
            }
        };
        beforeEach(function () {
            inputField.inputmask("999-99-9999");
        });

        it("applies a mask to the field with MaskedInput attribute", function () {
            inputField.val('1');
            expect(inputField.val()).toEqual("1__-__-____");
        });

        it("allows deletion of the input", function () {
            inputField.val('333224444');
            deleteInput();
            expect(inputField.val()).toEqual("");
        });

        it("allows input after deleting input from field", function () {
            inputField.sendKeys('333224444');
            deleteInput();
            expect(inputField.val()).toEqual("");
            inputField.sendKeys("123");
            expect(inputField.val()).toEqual("123-__-____");
        });

        it("allows inserting values with INSERT mode on", function () {
            inputField.sendKey(keys.INSERT);
            inputField.sendKeys("123");
            expect(inputField.val()).toEqual("123-__-____");
        });
    });

Hope this helps with the advance on Android and mobile devices. 😄

Resources:
Thread on the return 0 issue: https://code.google.com/p/chromium/issues/detail?id=118639
Test for return 0: http://goo.gl/n7IKjF

@RobinHerbots RobinHerbots modified the milestones: 2.6, 2.7 Mar 24, 2014
@RobinHerbots RobinHerbots self-assigned this May 20, 2014
@RobinHerbots
Copy link
Owner

@rizowski ,

Finally got to read the docs.

I will try out the following events. Maybe they will be accurate on android chrome.
compositionstart
compositionupdate
compositionend

@RobinHerbots
Copy link
Owner

@RobinHerbots
Copy link
Owner

@greengerong
Copy link

I meet same problem on my nexus 5 chrome(version 35), Any idea for it?

@RobinHerbots
Copy link
Owner

The idea is to react on the composition events, but I didn't found the time
yet to experiment.

2014-07-02 17:05 GMT+02:00 green notifications@github.com:

I meet same problem on my nexus 5 chrome(version 35), Any idea for it?


Reply to this email directly or view it on GitHub
#465 (comment)
.

@RobinHerbots RobinHerbots modified the milestone: 3.2 Jul 9, 2014
@jason-linthwaite
Copy link

Hi Robin,

Just wondering if this is fixed?

@RobinHerbots
Copy link
Owner

@jason-linthwaite ,

I haven't found the time to further investigate, ... so no further progress

@jason-linthwaite
Copy link

Ok thanks for the update Robin. Do you know if there is anyway to workaround or test the browser and remove masking if it is Android > 4?

@rizowski
Copy link
Author

rizowski commented Aug 4, 2014

@jason-linthwaite You could do some checking on the navigator.userAgent for ignoring certain versions. I know Robin uses http://jsfiddle.net/Tpr6N/15/ for testing and has the line I am speaking of. You can do a string .indexOf() for certain versions of android and wrap the $.inputmask() initializer in an if statement so that only versions below XXX is shown.

@sollipse
Copy link

Robin,

by "compositioning", do you mean the IME keyboard moving the cursor around and not registering certain softkeyboard events?

@RobinHerbots
Copy link
Owner

@sollipse ,

Exactly

@sollipse
Copy link

To clarify, this issue only crops up on the default android browser, and only on sub-4.4 devices?

@RobinHerbots
Copy link
Owner

No also on the other browsers.

@wowDaiver
Copy link

I finded temporary solution for phone mask. Set type input field as "tel"

My device Samsung Galaxy S3

@JoeyHoutenbos
Copy link

Using the input type "tel" does indeed work, but this mask "9999AA" is not working on Android (Galaxy Tab 3) with the default Samsung keyboard. When I switch to another keyboard this is working or when I turn off the "Predictive text" option. Also a external (bluetooth) keyboard is working..
There are just some softkeyboards that aint working.. If I can be of any assistance with solving the Android problems let me know

@jason-linthwaite
Copy link

Robin, I haven't looked at this for a while and just had a brief look through the posts above - did you incorporate a fix? Seems like a tricky problem...

@RobinHerbots
Copy link
Owner

@jpgamaral
Copy link

What's the status on this? I am also having issues using a date mask on Android.

@RobinHerbots
Copy link
Owner

@jpgamaral ,

I guess as long there is no way to control the IME, there is no real solution to the problem. See previous comment.

@jpgamaral
Copy link

@RobinHerbots, okay thank you.

@danielnass
Copy link
Contributor

Hey guys, how are you?

I found something that can help with Samsung keyboard or other modified keyboards.

Here one guy told to use oninput event, that is similar to onchange event, but occurs immediately after the value of an element has changed, while onchange occurs when the element loses focus, after the content has been changed. http://stackoverflow.com/a/33646354

And here are more information. The last comment says to use onkeyup event to fix samsung keyboard. http://stackoverflow.com/questions/17139039/keycode-is-always-zero-in-chrome-for-android

I'll be glad if can help more.

@RobinHerbots
Copy link
Owner

Cuurent implementation only acts on the input event as the keypress is not fired. Compositionevents are ignored in mobile.

@sayannisur
Copy link

Hi,

I am using this inputmask js plugin latest one in my code.
But the problem with duplicate characters seems to exist in samsung note 2.
Is there any latest soln to this?
I am using the below code 👍 $("input[data-rule-accnumber='true']")

            .inputmask("9999999999",
         {
       // $("input[id$=txtAccountNumber]").mask("9999999999",
         // {
                "oncomplete": function () {
                    $(this).parent().removeClass('invalid').addClass('valid');
                    $(this).attr('data-mask', 'valid');
                },
                "onincomplete": function () {
                    $(this).parent().removeClass('valid').addClass('invalid');
                    $(this).attr('data-mask', 'invalid');
                }

            });

Regards,
Sayani Sur

@zgr024
Copy link

zgr024 commented Sep 9, 2016

Still no solution to this error. Using various Galaxy devices and browsers. Input mask plugin is rather useless these days it seems.

Android Devices Tested
Galaxy S5
Galaxy S6 Edge +
Galaxy S7 Edge
Galaxy Note 7 (hasn't exploded yet)

On a side note, the issue is a bit different on Apple devices but still an issue.

Apple Devices Tested
iPhone 5
iPhone 5s
iPhone 6
iPhone 6s

@nicklello
Copy link

I'm not clear on if this was fixed/worked around or not....

@zgr024
Copy link

zgr024 commented Sep 15, 2016

The issue has not been fixed. The work around is to use a different masking plugin that doesn't display the mask format on focus but rather adds the mask as the user types.

jQuery Mask Plugin seems to work fine, at least the version i have which is v1.5.3. Latest as of this post is 1.14.0

github.com/igorescobar/jQuery-Mask-Plugin

@RobinHerbots
Copy link
Owner

RobinHerbots commented Sep 15, 2016

@nicklello , @zgr024 ,

The question is what do you call supported!

Try both plugins with predictive text on ..... and see them both fail. (the reason see previous comments)

@RobinHerbots
Copy link
Owner

@zgr024 ,

Can you have a try with the current version on github and give your thoughts on it. Also include the inputmask.css from within the extra folder.

@whooehoo
Copy link
Contributor

whooehoo commented Oct 4, 2016

@RobinHerbots ,

Hi, Robin!
I think i found problem and decision on Android.

In initializeColorMask function you getBoundingClientRect from input, but it's wrong, because getBoundingClientRect get top, left, right ,bottom, height, width relative to window.

There's a simple example, used the last version of jquery.inputmask.bundle.js.

https://whooehoo.github.io/test

Just turn on device inspector in Chrome or open page on Android device.

My pull request on this bug.

#1404

@br4in3x
Copy link

br4in3x commented Mar 30, 2017

Was facing same issue, and as quick fix - switched to another library. But they also had exactly same problem and it was fixed, check here.

@uebbi
Copy link

uebbi commented Jan 26, 2018

Nevermind! Bug fixed on current version! My bad!

Same problem here! Tested on Android 7 - Chrome and Firefox!

Any help?!

@mgomez
Copy link

mgomez commented Jan 29, 2018

@uebbi v3.3.11?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests