Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Blanking out datefield under 6.0.2 does not trigger change event

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-20833 in 6.0.3.
  1. #1
    Ext JS Premium Member
    Join Date
    Aug 2010
    Posts
    66

    Default Blanking out datefield under 6.0.2 does not trigger change event

    Hi,

    We've had a pretty serious breakage result from upgrading from 6.0.1 to 6.0.2. In a nutshell, the change event for the datefield component no longer fires when you blank out the field, and worse, calling getValue() on the field returns the PREVIOUS date selected (and that's also what gets submitted if you do so). Because we have a need for the change event to trigger some logic in all cases in one app we have, this is pretty big for us.

    Here's a simple example to demonstrate:
    Code:
    Ext.onReady(function() {
      new Ext.Viewport({
        items : [
          { xtype : "datefield", id : "df",
            listeners : {
              change : function() {
                console.log("change event");
              }
            }
          }, 
          { xtype : "button", text : "getValue",
            handler : function() {
              console.log(Ext.getCmp("df").getValue());
            }
          }
        ] 
      });
    });
    Sequence to follow to replicate under 6.0.2:

    1. Select a date
    2. Note the log message indicating change event fired
    3. Go into the field's textbox part and manually blank out the field
    4. Note that NO log message results indicating change event fired
    5. Click the button and note that console message indicates the value that was selected

    Now, switch over to 6.0.1 with the same code and you'll see that the change event fires twice, once for setting the date and once for clearing the field, and clicking the button shows null for the field value, as expected.

    I notice in the changelog: "EXTJS-20610 Datefield does not fire onchange when selecting date"... that sounds suspiciously like the kind of thing that could have somehow resulted in this problem, or at least it's not a bad guess

    Thanks,
    Frank

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,250

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Apr 2016
    Posts
    1

    Default

    Easy workaround for Ext.form.field.Date (add v===null)

    Code:
    onBlur: function(e) {
    
            var me = this,
                v = me.rawToValue(me.getRawValue());
    
            if (v === null || Ext.isDate(v)) {
                me.setValue(v);
            }
    
            me.callParent([e]);
        }

  4. #4
    Ext JS Premium Member
    Join Date
    Aug 2010
    Posts
    66

    Default

    Thanks, that does indeed appear to do the trick

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    914

    Default

    In 6.0.1 change event was fired both when user selects a date using date picker AND when he types the new date directly in the input field. Due to the following stupid getValue() overload introduced in 6.0.2 the change event is no longer triggered when user types the date directly, because the newly introduced "this.rawDate" private property does not change in setRawValue() method.
    PHP Code:
    getValue: function() {
        return 
    this.rawDate || null;

    Also, datefield's setValue() method is no longer chainable and the copy-pasted getValue() method description no longer corresponds to reality.

    And one more thing: the bug (EXTJS-20610 Datefield does not fire onchange when selecting date) it was supposed to fix doesn't seem to exist in 6.0.1. Change event is fired correctly in 6.0.1 when selecting date using date picker.

  6. #6
    Sencha Premium Member yorl1n's Avatar
    Join Date
    Mar 2015
    Location
    Germany
    Posts
    294

    Default

    I will connect to this bug. None of the key-events are working with Datefield. One year of bug fixing to break a core functionality...Now we should wait one more year to get new fixes and grow up new workarounds...

  7. #7
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    Sorry guys, I fixed a Y2K bug in date field, and the checkChange() and validate functionality regressed. It has since been fixed. I should show up in new builds soon.

  8. #8
    Ext JS Premium Member
    Join Date
    Oct 2008
    Location
    California, USA
    Posts
    76

    Exclamation

    This claims to be fixed in 6.0.3 and the fix is in the latest release notes but I am still having the issue.

    https://www.sencha.com/forum/showthr...-date-to-blank

  9. #9
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    Quote Originally Posted by Supergibbs View Post
    This claims to be fixed in 6.0.3 and the fix is in the latest release notes but I am still having the issue.

    https://www.sencha.com/forum/showthr...-date-to-blank
    EXTJS-20833 has not been merged yet. Sorry for the delay.

  10. #10
    Ext JS Premium Member
    Join Date
    Oct 2008
    Location
    California, USA
    Posts
    76

    Default

    It's listed in the release notes in the latest nightly...

Page 1 of 2 12 LastLast

Similar Threads

  1. how to trigger button handler after firing change event in field.
    By aimer311 in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 13 Feb 2012, 5:53 AM
  2. for a spinner, setValue can't trigger the change event, why?
    By linuxyf in forum Sencha Touch 2.x: Discussion
    Replies: 1
    Last Post: 7 Feb 2012, 8:54 AM
  3. How to manually trigger an orientation change event
    By Martin1982 in forum Sencha Touch 1.x: Q&A
    Replies: 1
    Last Post: 3 Jan 2012, 7:33 AM
  4. Replies: 7
    Last Post: 21 May 2011, 5:18 AM
  5. DateField trigger event issue
    By luizgarruda in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 22 Jun 2010, 8:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •