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

fix: fix android chrome support #105

Merged
merged 1 commit into from
Aug 5, 2020
Merged

fix: fix android chrome support #105

merged 1 commit into from
Aug 5, 2020

Conversation

jlabanca
Copy link
Contributor

This change fixes some issues in Android Chrome. Android Chrome doesn't send keypress event, so we rely on input events instead. The old input event handler code was basically duplicating code in the keypress handler, but it wasn't as robust, especially after we added support for natural mode. For example it assumed the cursor was always at the end of the input, so it isn't possible to add or delete a digit in the middle of the number. It doesn't allow you to add digits at all in natural mode.

The new code delegates to the existing keypress handler when adding digits, resulting in consistent functionality with desktop browsers. The algorithm is simple. Figure out what character was added, restore the old string, then call handleKeyPress with the new character.

I also tweaked the remove logic by setting the selection index before calling remove number, so it's now possible to remove a digit at any index.

In addition to adding unit tests, I tested this on an Android Simulator and my personal android device

Addresses issues #90 and #100.

cc: @nbfontana

This change fixes some issues in Android Chrome. Android Chrome doesn't send keypress event, so we rely on input events instead. The old input event handler code was basically duplicating code in the keypress handler, but it wasn't as robust, especially after we added support for natural mode. For example it assumed the cursor was always at the end of the input, so it isn't possible to add or delete a digit in the middle of the number. It doesn't allow you to add digits at all in natural mode.

The new code delegates to the existing keypress handler when adding
digits, resulting in consistent functionality with desktop browsers. The
algorithm is simple. Figure out what character was added, restore the
old string, then call handleKeyPress with the new character.

I also tweaked the remove logic by setting the selection index before
calling remove number, so it's now possible to remove a digit at any
index.

In addition to adding unit tests, I tested this on an Android Simulator
and my personal android device

Addresses issues #90 and #100
@thiendang18
Copy link

@nbfontana please check. Thanks

@nbfontana
Copy link
Owner

Looking into it

@nbfontana nbfontana closed this Aug 5, 2020
@nbfontana nbfontana reopened this Aug 5, 2020
@nbfontana nbfontana merged commit d2b2106 into nbfontana:master Aug 5, 2020
@nbfontana
Copy link
Owner

@jlabanca Sorry if I'm late on this one and other updates in ngx-currency. I'm actually thinking in migrating this repository to a Currency org with some other collaborators, would you be interested? If so, you could e-mail me (e-mail on profile) with you discord or something so we can organize it... No pressure Ahaha

@nbfontana
Copy link
Owner

This change is live at ngx-currency@2.4.0

@jlabanca
Copy link
Contributor Author

jlabanca commented Aug 6, 2020

Thanks for the review. I sent you an email with my discord.

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

Successfully merging this pull request may close these issues.

None yet

3 participants