Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#9671 closed defect (fixed)

dijit.NumberTextBox (and related) do use editOptions pattern with custom pattern in constraints

Reported by: Phil DeJarnett Owned by: Douglas Hays
Priority: high Milestone: 1.4
Component: Dijit - Form Version: 1.3.2
Keywords: NumberTextBox CurrencyTextBox Cc:
Blocked By: Blocking:

Description

Due to this line (line 93):

constraints = dojo.mixin(dojo.mixin({}, this.editOptions), constraints);

If a custom pattern is supplied (say, to allow -$1.00 or 00051 formatted values), the edit pattern never gets applied, and it becomes difficult to edit other formats.

I believe the line should be modified, to give editOptions preference over constraints (so a user can still override editOptions.pattern is necessary):

constraints = dojo.mixin({}, constraints, this.editOptions);

Also, as above, there is no reason to call mixin multiple times, as it handles multiple arguments.

Attachments (1)

9671.patch (3.3 KB) - added by haysmark 10 years ago.
Fixes #9671. isValid now checks with parse to determine whether the user's partial input is valid. _getValueAttr uses more strict detection of exponential values.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 10 years ago by Douglas Hays

Milestone: tbd1.4
Owner: set to Douglas Hays

comment:2 Changed 10 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

(In [19941]) Fixes #9671, #9729. Changed constraints mixin to add editOptions last. Added test for editOptions to test_validate.html. Add specialized isValid to NumberTextBox? to return the correct isValid when editing and the displayed value has not yet been formatted. This happens when ENTER is pressed inside a Form widget. Fixed an automated test oops.

comment:3 Changed 10 years ago by bill

Resolution: fixed
Status: closedreopened

[19941] breaks Spinner_mouse.html, specifically that typing "0.5" into the first spinner is no longer flagged as an error (it doesn't turn yellow).

The first spinner has constraints:

<input dojoType="dijit.form.NumberSpinner"
	...
	constraints="{max:1550,places:0}"

comment:4 Changed 10 years ago by Douglas Hays

Priority: normalhigh

comment:5 Changed 10 years ago by Douglas Hays

Status: reopenednew

comment:6 Changed 10 years ago by Douglas Hays

Status: newassigned

comment:7 Changed 10 years ago by bill

Oops, in [20441] I just changed the Spinner_mouse.html test to type "0.a" rather than "0.5", thinking that the latter *wasn't* invalid. Please change it back after fixing this.

Changed 10 years ago by haysmark

Attachment: 9671.patch added

Fixes #9671. isValid now checks with parse to determine whether the user's partial input is valid. _getValueAttr uses more strict detection of exponential values.

comment:8 Changed 10 years ago by haysmark

I attached a potential fix.

comment:9 Changed 10 years ago by Douglas Hays

Resolution: fixed
Status: assignedclosed

(In [20515]) Fixes #9671. Call parse to detect invalid fractional values. Check for exponential notation that is erroneously rejected by parse. Allow HOME and END to edit invalid values. Added several automated Spinner tests.

comment:10 Changed 10 years ago by Adam Peller

(In [20555]) replace eval with Math expression from [20515]. Refs #9671

comment:11 Changed 9 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.