Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#17826 closed defect (fixed)

[regression] TextBox: on("keypress", callback) never fires callback

Reported by: bill Owned by: bill
Priority: undecided Milestone: 1.9.4
Component: Dijit Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

Starting in 1.9.1 (see #17154), TextBox?.on("keypress", ...) never fires.

According to Dylan, this fix actually breaks a pretty common pattern with ValidationTextBox?, which is to prevent/mask invalid input. Prior to this change, you could extend ValidationTextBox? with something like:

require([
    "dojo/_base/declare",
    "dijit/form/ValidationTextBox",
    "dojo/domReady!"
], function (declare, ValidationTextBox) {
    function isNumber(n) {
        return !isNaN(parseFloat(n)) && isFinite(n);
    }
    var InputBox = declare([ValidationTextBox], {
        buildRendering: function () {
            this.inherited(arguments);
            this.on("keypress", function (event) {
                var value = this.get("value") + event.charOrCode;
                if ((/\s/).test(event.charOrCode) || !isNumber(value)) {
                    // if value is not a number, ignore it
                    event.preventDefault();
                }
            });
        },
        validator: isNumber
    });
    new InputBox().placeAt(document.body);
});

Change History (3)

comment:1 Changed 6 years ago by bill

Milestone: tbd1.9.4
Owner: set to bill
Status: newassigned

comment:3 Changed 6 years ago by Bill Keese <bill@…>

In 289f96b2592e3bb23a714256ab1d48bcbfaa3bce/dijit:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:2 Changed 6 years ago by Bill Keese <bill@…>

Resolution: fixed
Status: assignedclosed

In 073c1a07a3fc26901b63bda9f1e195fdaf7e9499/dijit:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 
Note: See TracTickets for help on using tickets.