Fixed: Decimal numbers not displayed correctly in input type=number (OFBIZ-13297)#913
Fixed: Decimal numbers not displayed correctly in input type=number (OFBIZ-13297)#913florianMo wants to merge 2 commits into
Conversation
|
Hi Florian, I just tested, we have still the load and decimals value change issue at https://localhost:8443/catalog/control/EditProductPrices?productId=GZ-1000 Despite having So it looks like a load issue. But if you try to enter 15,99 only 15 is saved. I know it's a WIP and a draft PR :) HTH |
|
Hi @JacquesLeRoux , it is related to my second point (as far as I know now, not sure yet what's happening here). When entering a decimal value in an input (dot or comma), we always get a decimal string with a dot in After the value is saved, we have the same process for the display : OFBiz will grab the value from DB, and stringify it using the user locale. If the value is I was able to "fix" this by using To summarize, I feel like using It should be noted that in HTML, locale can be defined on all elements, as a |
|
Thanks Florian, indeed we need to take decisions. Better do that openly on dev ML, the more brains the better. |
|
Hi @florianMo, I noticed the new patch is shorter than the last one, normal? |
This is a quick fix, not supposed to make its way to a release without further discussions! OFBIZ-13297
|
|
Ah OK, seems still a WIP :) |
|
@JacquesLeRoux the implementation of the step attribute is ready for review, the last commit about always using |
|
Thanks Florian, naïve but working 👍 |
|
@florianMo, I'm looking at the test issue |
|
thanks @JacquesLeRoux , I guess this test checks that the current timezone is used to parse numbers ? And my niave solution breaks that ? |
|
Possible indeed @florianMo , I'll get back on this afternoon, not an hurry ;) |
|
The issue is at ObjectTypeTests::simpleTypeOrObjectConvertTest L128 The wanted argument is 12,345.67. At least on a French PC the value is 12 345,67. I did not test with another language. So, in this specific case, the problems are the decimal and thousands separator https://en.wikipedia.org/wiki/Decimal_separator#Digit_grouping I'm not sure, but since it's only a test, maybe it's easier to force separators value, say the English ones ("," and ".') and modify the calculated value to correspond to "wanted". Adapting the "wanted" values upstream in function of local language, eg at would be another solution. I did not change nor tested anything yet. |
|
Thinking about it, only the 2nd solution is serious. The 1st one is like testing 1=1 :) |
|
Thank you for your work Florian, I'm closing after fixing the test issue. |
|
Thanks @JacquesLeRoux , is there a specific reason for not merging this PR, and creating a new commit instead ? By doing this we lose traceability (who did this, the original PR description where I describe the whole thing) |
|
Hi Florian, You are right, I should have pushed the PR just before fixing the test issue. That would have been better. Unfortunately It's now too late as, unlike with Subversion, it's complicated to change commits comments once pushed with Git. But don't worry people interested by these information can still found it by following the Jira and information in it, notably the PR link. On the other hand alas indeed "git blame" does not help, I'm sorry. The principal reason is that I forgot about the PR. Mostly because I crossed an OS issue while working on the test issue as I explained at bottom of the commit comment. I finally fixed it. But, in my defense, it took me all my attention that's why I mostly forgot the rest. |
|
OK @JacquesLeRoux I understand ! Not a big deal indeed. |



Fixed: Decimal numbers not displayed correctly in input type=number
(OFBIZ-13297)
<input type="number"/>does not accept decimalsNow that we use
<input type="number"/>(https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number, https://issues.apache.org/jira/browse/OFBIZ-13183) to display numeric values in forms, it is not possible to enter decimal values.We need to support the
stepattribute (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#step), and useanyas default value, sinceanywill allow any decimal value. This means adding a newstepattribute on the<text/>form field, and render it as astepattribute on the HTML<input type="number"/>.Supporting this attribute, developer will be able to define which kind of value he expects (integer, one decimal, two decimals...).
<input type="number"/>does not display decimal values correctly<input type="number"/>are sensitive to the decimal separator used in theirvalueattribute. Depending on the browser and the lang used, an input may or may not display its value in the HTML field. For example :<input type="number" lang="en" value="1.2"/>-> displays1.2<input type="number" lang="en" value="1,2"/>-> displays1,2<input type="number" lang="fr" value="1.2"/>-> displays1,2<input type="number" lang="fr" value="1,2"/>-> displays1,2<input type="number" lang="en" value="1.2"/>-> displays1,2<input type="number" lang="en" value="1,2"/>-> displays nothing<input type="number" lang="fr" value="1.2"/>-> displays1,2<input type="number" lang="fr" value="1,2"/>-> displays nothingIt vould seem reasonable to always use the same locale (
enfor example) to format numeric values before inserting it in a HTML input, and let the browser decide which decimal separator to use.Thanks: Néréide team