1. #1
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default [2.1][DUP][OPEN] Combo forceSelection,allowBlank,emptyText & lastSelectionText

    [2.1][DUP][OPEN] Combo forceSelection,allowBlank,emptyText & lastSelectionText


    Steps to reproduce
    1. specify an emptyText config
    2. set forceSelection:true
    3. select a value from the combo's dropdown list
    4. clear the combo's value and click anywhere in the document so that the combo loses focus
    5. the combo's lastSelectionText is incorrectly displayed as the combo's emptyText


    test case:
    Code:
    Ext.onReady(function() {
        new Ext.form.ComboBox({
            forceSelection: true,
            allowBlank: true, // default = true... specified it again for clarity
            store: ['Some value'],
            emptyText: 'I am empty',
            renderTo: document.body
        });
    });
    suggested fix:
    Code:
    Ext.override(Ext.form.ComboBox, {
        // private
        doForce : function() {
            if (this.el.dom.value != this.emptyText && this.el.dom.value.length > 0) {
                this.el.dom.value = this.lastSelectionText === undefined? '' : this.lastSelectionText;
                this.applyEmptyText();
            }
        }    
    });
    note: even with this fix, calling myCombo.getValue() still returns the combo's last selected value when the field is empty (i.e. when allowBlank = true).
    Last edited by mystix; 3 Aug 2008 at 8:10 PM. Reason: edit

  2. #2
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    228
    Vote Rating
    4
    XASD is on a distinguished road

      0  

  3. #3
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    that's a different problem actually.

    theoretically, if no emptyText is specified (as in the example in the thread you linked to), the combo should be allowed to be completely empty.

    in the case i posted above, the emptyText config was specified, so the emptyText (and not the lastSelectionText) should be displayed when the field has been blanked.

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    4
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    There have actually been several closely related versions of this issue posted. It's a little more complex because while the proposed change makes sense for in-page combos, it does not necessarily make sense for combos in editors, where clicking outside the editor should be interpreted as a non-selection cancel event. Also the combination of different combo options and modes combine to make handling things consistently everywhere a might tricky. I've looked into this a little previously and it's on our list, but it's going to take a little more work to handle appropriately.

  5. #5
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default DUP

    DUP


    Flashback... didn't I stumble upon this a few months ago?

  6. #6
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    4
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    Counting these threads, I'm now tracking probably 8-10 that are in some way related to combo forceSelction/focus/blur value setting/clearing. There are also a couple of threads of combo feature enhancements that would be nice to add. I wanted to do some of this for 2.2 but it got a little hairy when I got into it so it's not going to happen at the moment. However, I can assure you that there will be some combo improvements in the following release.

  7. #7
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    Quote Originally Posted by Condor View Post
    Flashback... didn't I stumble upon this a few months ago?
    my bad.

  8. #8
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    228
    Vote Rating
    4
    XASD is on a distinguished road

      0  

    Default


    Quote Originally Posted by mystix View Post
    theoretically, if no emptyText is specified (as in the example in the thread you linked to), the combo should be allowed to be completely empty.
    Yes,it's empty but only visually,real "value" remains equal to previously selected one-it's serious problem if you have valueField!=displayField.So,it's bug,maybe a little different(I believe related to you issue) but bug anyway.

    Thanks.

  9. #9
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    NL
    Posts
    608
    Vote Rating
    1
    mdissel is on a distinguished road

      0  

    Default


    This is still an issue in ext 2.2. Can this be solved?

  10. #10
    Ext User
    Join Date
    Jul 2008
    Posts
    1
    Vote Rating
    0
    simo is on a distinguished road

      0  

    Thumbs up


    you can add an else with the if ,to set the value of combobox to null,like that:
    Code:
     var mycombobox = new........
       
    doForce : function() {
     if (this.el.dom.value != this.emptyText && this.el.dom.value.length > 0) {
                this.el.dom.value = this.lastSelectionText === undefined? '' : this.lastSelectionText;
                this.applyEmptyText();
            }
      else{
          mycombobox.setValue();
    }
    }
    so now the value of empty text is null.
    Last edited by mystix; 10 Sep 2008 at 5:56 PM. Reason: post code in [code][/code] tags. see http://extjs.com/forum/misc.php?do=bbcode#code