Opened 3 years ago

Closed 3 years ago

#18776 closed defect (patchwelcome)

onChange event on TextBox after set("value", ..., false) then blur

Reported by: ITA003 Owned by: bill
Priority: undecided Milestone: tbd
Component: Dijit - Form Version: 1.9.4
Keywords: Cc:
Blocked By: Blocking:

Description

HI, I developed a custom website using dojo 1.9.4 and I've a modal popup with a form. In this form I've a DateTextBox? field with onChange event that should be start when the date change. While I open the modal popup I fill the DateTextBox? value with a date using this code:

var updObj = dijit.byId('IDDateTextBox');
updObj.set('value', '2015-01-16', false);

The third parameter because I don't need to fire onChange event when I set this value, but if the user change the value, the onChange event must fire.

But when I open the calendar, without change any value, and exit from the calendar the onChange event fire also the value don't change. Is this a bug or I wrong something?

This is the HTML code of DateTextBox? element:

<input name="TDG004txtDtValuta" type="text" maxlength="10" id="TDG004txtDtValuta" class="InputField" required="true" data-tableref="NOTASPESE_RIGHE" data-fieldref="dtvaluta" data-postback="n" onchange="onChangeFieldValue(&#39;TDG004&#39;);updateCambioFromValuta(83,&#39;TDG004ddlDsValuta&#39;,&#39;TDG004txtDtValuta&#39;,&#39;TDG004txtNmCambio&#39;)" data-dojo-type="dijit.form.DateTextBox" />

Change History (3)

comment:1 Changed 3 years ago by bill

Hmm, I don't know. What do you mean by "While I open the modal popup"? Is it the order below?

  1. Open the dropdown
  2. Change the DateTextBox?'s value
  3. Close the dropdown

I don't think we've done any tests or even thought about changing the DateTextBox?'s value while the dropdown is open.

comment:2 Changed 3 years ago by ITA003

Hi, the steps are:

  1. Change the DateTextBox?'s value
  2. Show the Dialog
  3. Open Dropdown (I don't change any date value)
  4. Close Dropdown. The onChange event method starts even if the value is still the same

Thanks.

comment:3 Changed 3 years ago by bill

Resolution: patchwelcome
Status: newclosed
Summary: onChange event on DateTextBox fire on open calendaronChange event on TextBox after set("value", ..., false) then blur

I see... actually, you left off step 5, right? To blur the DateTextBox? by clicking somewhere else or tabbing away.

This has nothing to do with DateTextBox? or the Calendar dropdown per se. I can reproduce the problem in test_DateTextBox.html by

  1. run dijit.byId("local").set("value", "2016-01-14", false); in the console
  2. click the first DateTextBox?
  3. click somewhere else on the page

The "onChange" notification next to the first textbox indicates that onChange was called after the last step.

It's due to this code in _TextBoxMixin.js:

_setBlurValue: function(){
        // Format the displayed value, for example (for NumberTextBox) convert 1.4 to 1.400,
        // or (for CurrencyTextBox) 2.50 to $2.50

        this._setValueAttr(this.get('value'), true);
},

So, it's a bug. If someone wants to supply a patch for this (and as usual an automated test) then I'd be happy to look at it.

Note: See TracTickets for help on using tickets.