This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 42000 - Unable to use comma (",") as decimal point
Summary: Unable to use comma (",") as decimal point
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-06-20 15:24 UTC by Andreas
Modified: 2017-05-27 15:20 UTC (History)
7 users (show)

See Also:
Tags: Android ac
Is this bug a regression?: ---
Last known good build:


Attachments
repro solution (268.92 KB, application/zip)
2016-06-22 18:27 UTC, Jimmy
Details

Description Andreas 2016-06-20 15:24:44 UTC
I live in sweden and my phone/app uses Swedish locale (Sv_SE).
What I want is an Entry field for decimal values.

I create an Entry field and set the Keybord to "Numeric". ( <Entry Keyboard="Numeric"/> )

This gives me a numeric keypad with BOTH "," and "." visible. However, pressing "," has no effect. Only the "." is accepted. 

I also tried creating a custom renderer, like suggested here:
https://bugzilla.xamarin.com/show_bug.cgi?id=25373
to set InputType = InputTypes.ClassNumber | InputTypes.NumberFlagSigned | InputTypes.NumberFlagDecimal

However, still only "." was accepted.

The device is a Google/LG Nexus 5 (phone) using Google Keyboard as it's keyboard.

Since my users here in sweden are used to write one and a half like "1,5" they will end up Writing "15" since the "," is ignored. This is NOT OK!

Please don't suggest to use
KeyListener = DigitsKeyListener.GetInstance("-0123456789,")
since this will force _me_ to check for valid decimal values (the user might otherwice write things like "3,5,4,3,,,9")
Comment 1 Jimmy 2016-06-22 18:27:10 UTC
Created attachment 16444 [details]
repro solution

I think the issue is more general: the ‘,’ and ‘-‘ characters on the numeric keyboard are not inputted regardless of the system language. I’ve attached a repro project that demonstrates this.

### Steps to Reproduce 
1. Run the Android project
2. Attempt to enter a comma in the Entry 


### Workaround
A workaround is to use a custom Entry renderer and use:

> KeyListener = DigitsKeyListener.GetInstance("-0123456789,")

If the Entry is bound to a double, the value entered should be parsed automatically to prevent multiple ‘,’ characters. However there is another bug affecting this (bug#42084). But there is a workaround for that issue as well provided in the report.
Comment 2 adrianknight89 2016-09-30 02:42:11 UTC
See https://github.com/xamarin/Xamarin.Forms/pull/396

Andreas, I talked about the way to validate the text. I don't believe the keyboard should be responsible for data validation. To you, 3,5,4,3,,,9 might be incorrect behavior, but there are many ways to represent numbers internationally and custom logic can be required to generate custom patterns.
Comment 3 Rui Marinho 2017-02-17 11:18:23 UTC
Should be fixed in 2.3.5-pre1
Comment 4 Lars 2017-05-26 10:13:17 UTC
Tested in 2.3.5.239-pre3 and it does work. However, the solution provided is not very user friendly. The button that previously showed a period "." now displays ".-,+" instead. Users will then have to triple click that button every time they want to write a comma.

This might be ok, if you only have to use it once in a while, but when regularly having to input multiple numbers this quickly becomes cumbersome.

In my opinion, there should be a separate column for these symbols on the numeric keyboard, or at least the comma should be placed first on locales that use comma as decimal separator, so the user only have to press the button once.
Comment 5 E.Z. Hart 2017-05-27 02:00:55 UTC
(In reply to Lars from comment #4)
> Tested in 2.3.5.239-pre3 and it does work. However, the solution provided is
> not very user friendly. The button that previously showed a period "." now
> displays ".-,+" instead. Users will then have to triple click that button
> every time they want to write a comma.
> 
> This might be ok, if you only have to use it once in a while, but when
> regularly having to input multiple numbers this quickly becomes cumbersome.
> 
> In my opinion, there should be a separate column for these symbols on the
> numeric keyboard, or at least the comma should be placed first on locales
> that use comma as decimal separator, so the user only have to press the
> button once.

Lars,

I just fired up my emulator and I don't see a button with ".-,+"; I see a "," button and a separate button for ".". So this might be an issue for specific devices or API levels that we overlooked. What device and version of Android are you seeing this behavior on?
Comment 6 Lars 2017-05-27 15:20:39 UTC
The app we are making is primarily for use on tabs, but I have also tested it on my phone. I get the same issue on both devices.

Tab: Samsung Galaxy Tab Active 8.0" 16GB (OS: Android 5.1.1)
Phone: Samsung Galaxy S6 (OS: Android 7.0)

I have now tested on an emulator as well and I can see that you are right. There is a separate comma button there. So it could be that this is a problem that only affects Samsung devices.

Note You need to log in before you can comment on or make changes to this bug.