Opened 8 years ago

Closed 2 years ago

#10582 closed defect (patchwelcome)

dijit.form.NumberTextBox incorrectly handle percentages

Reported by: Jean-Rubin Leonard Owned by:
Priority: high Milestone: 1.13
Component: Dijit - Form Version: 1.4.0
Keywords: NumberTextBox percent percentage Cc:
Blocked By: Blocking:

Description (last modified by bill)

dijit.form.NumberTextBox is unable to handle percentages as they are used in real life. In the attached text file there are three examples.

In the first example I create a ntb with constraints="{type: 'percent'}". If you enter ‘10%’. Its all good. If you leave the ntb and come back to it, it’s edited and shows 0.1. This immediately triggers the invalidMessage which it should not. If we enter 10.34% it doesn’t work and specifying constraints="{type: 'percent',places:2}" doesn’t change that either. This is not a localization issue as 10,34% doesn’t work either. Allowing the use of decimal in the ntb and allowing users to enter 0.1234 or 12.34% would go a long way into making it usable in real life application. The current features aren’t adequate.

We face the same kind of problem when using constraints="{pattern: '##0.####%'}". This also have the further disadvantage of not being globalized as the pattern is hard coded and will not be changed according to the users’ locale.

Attachments (2)

numberTextBoxes.html (1.2 KB) - added by Jean-Rubin Leonard 8 years ago.
textboxesUpdated.html (1.4 KB) - added by Jean-Rubin Leonard 8 years ago.

Download all attachments as: .zip

Change History (12)

Changed 8 years ago by Jean-Rubin Leonard

Attachment: numberTextBoxes.html added

comment:1 Changed 8 years ago by bill

Description: modified (diff)
Owner: set to Douglas Hays

comment:2 Changed 8 years ago by Douglas Hays

Milestone: tbdfuture

Prereq on #10701

comment:3 Changed 8 years ago by Adam Peller

(In [21792]) Allow decimal places when parsing numbers type=percent. Fixes #10701, Refs #10582

Changed 8 years ago by Jean-Rubin Leonard

Attachment: textboxesUpdated.html added

comment:4 Changed 8 years ago by Jean-Rubin Leonard

There are three issues with the current state of the numberTextBox: 1) It seems that if we specify constraints, we must specify places for the textbox to be instantiated correctly. If we don't the parser stops with the error "parts[1] is undefined". 2) If we create the textbox with places:0 and enter 80%, get back of the numberTextbox and back into it to edit it, the number that shows is 1 instead of the expected 0.8. If we enter 20%, the number that appears is 0 instead of the expected 0.2 3) If we create the textbox with places:1 and enter 80.1%, get back of the numberTextbox and back into it to edit it, the number that shows is 0.8 instead of the expected 0.81. If we enter 20.1, it edits as 0.2 instead of the expected 0.2

comment:5 Changed 8 years ago by Adam Peller

(In [21951]) Redo r21792 to avoid exception when parts[1] is null and options.places is unspecified. Refs #10701, Refs #10582

comment:6 Changed 8 years ago by Adam Peller

(In [21971]) Strip out location-dependent timezone from date format test. Refs #10692 Add number percent test. Refs #10701, #10582

comment:7 Changed 7 years ago by bill

Component: DijitDijit - Form

comment:8 Changed 4 years ago by Douglas Hays

Owner: Douglas Hays deleted
Status: newassigned

comment:9 Changed 4 years ago by Douglas Hays

Status: assignedopen

comment:10 Changed 2 years ago by dylan

Milestone: future1.12
Resolution: patchwelcome
Status: openclosed

Given that no one has shown interest in creating a patch in the past 5+ years, I'm closing this as patchwelcome.

Note: See TracTickets for help on using tickets.