Opened 8 years ago

Closed 21 months ago

#10582 closed defect (patchwelcome)

dijit.form.NumberTextBox incorrectly handle percentages

Reported by: simpli 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 simpli 8 years ago.
textboxesUpdated.html (1.4 KB) - added by simpli 7 years ago.

Download all attachments as: .zip

Change History (12)

Changed 8 years ago by simpli

comment:1 Changed 8 years ago by bill

  • Description modified (diff)
  • Owner set to doughays

comment:2 Changed 8 years ago by doughays

  • Milestone changed from tbd to future

Prereq on #10701

comment:3 Changed 7 years ago by peller

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

Changed 7 years ago by simpli

comment:4 Changed 7 years ago by simpli

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 7 years ago by 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 7 years ago by peller

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

comment:7 Changed 6 years ago by bill

  • Component changed from Dijit to Dijit - Form

comment:8 Changed 4 years ago by doughays

  • Owner doughays deleted
  • Status changed from new to assigned

comment:9 Changed 4 years ago by doughays

  • Status changed from assigned to open

comment:10 Changed 21 months ago by dylan

  • Milestone changed from future to 1.12
  • Resolution set to patchwelcome
  • Status changed from open to closed

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.