Results 1 to 5 of 5

Thread: Combo boxes no longer assert their value.

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-16795 in 5.1.1.
  1. #1
    Sencha User
    Join Date
    Aug 2014
    Location
    Bath, UK
    Posts
    26
    Vote Rating
    3
      0  

    Default Combo boxes no longer assert their value.

    Ext version tested:

    • Ext 5.1.0.107
    Browser versions tested against:
    • Chrome
    Description:
    Make a combo box allowBlank: false. You can select a value and then delete it. Didn't used to work that way in older Ext versions.

    Steps to reproduce the problem:
    Created a fiddle here:

    https://fiddle.sencha.com/#fiddle/ibf

    To see the problem:
    1. Select a value from the drop down.
    2. Select the value.
    3. Delete the value.
    4. Now tab off.
    Rather than selecting the value that was chosen, the combo is empty.

    I suspect the problem is here:
    Code:
        assertValue: function() {        var me = this,
                value = me.getRawValue(),
                rec, currentValue,
                displayValue = me.getDisplayValue();
    
    
            if (me.forceSelection) {
                if (me.multiSelect) {
                    // For multiselect, check that the current displayed value matches the current
                    // selection, if it does not then revert to the most recent selection.
                    if (value !== displayValue) {
                        me.setRawValue(displayValue);
                    }
                } else {
                    // For single-select, match the displayed value to a record and select it,
                    // if it does not match a record then revert to the most recent selection.
                    rec = me.findRecordByDisplay(value);
                    if (rec) {
                        currentValue = me.value;
                        // Prevent an issue where we have duplicate display values with
                        // different underlying values.
                        if (!me.findRecordByValue(currentValue)) {
                            me.select(rec, true);
                        }
                    } else if (me.lastSelection) {
                        me.setRawValue(displayValue);
                    }
                }
            }
            me.collapse();
    
        },
    Specifically here
    Code:
                    else if (me.lastSelection) {
                        me.setRawValue(displayValue);
                    }
    Shouldn't we be doing a me.setValue(me.lastSelection) here?

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,237
    Vote Rating
    1015
      0  

    Default

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

  3. #3
    Sencha User
    Join Date
    Aug 2014
    Location
    Bath, UK
    Posts
    26
    Vote Rating
    3
      0  

    Default

    Applied a limited fix in a different fiddle here:

    https://fiddle.sencha.com/#fiddle/ica

    But this seems to show another problem.

    If you click into the combo and delete 'New York' then tab off, 'NEw York' is asserts as we'd like.

    If you select 'New Mexico', tab out, select New Mexico again, delete and tab off, 'New York' comes back.

  4. #4
    Sencha User
    Join Date
    Aug 2014
    Location
    Bath, UK
    Posts
    26
    Vote Rating
    3
      0  

    Default

    OK.

    I've been looking into what Ext 4 used to do.

    When you selected an item in a combo setValue was called and so me.lastSelection was set to the value. In Ext 5, updateValue is called instead.

    I've added an override to the fiddle:

    https://fiddle.sencha.com/#fiddle/ica

    running the fliddle as is will show the error (do as described above).

    If you rename CHANGETHISTOupdateValue to updateValue and run it again, you'll see the problem appears fixed.

    I'm not saying this is the correct fix, but it seems in the right area.

  5. #5
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    1,018
    Vote Rating
    125
      0  

    Default

    A backstage of fixing is the fact that now a ComboBox with "forceSelection: true" cannot be emptied - now it always restores the selected item. Regardless allowBlank is true or false (yes, it is only for validation and doesn't affect on input and I agree with that). Well, I tested with different ExtJS versions and saw that the behavior changes from one to another. It was possible to empty a ComboBox with "foceSelection: true", then it was not possible, then possible again. I see different people treat it in a different way. Someone treats one behavior as correct, someone - another. It might be good to eventually stick to the only behavior and, maybe, introduce a new setting to allow or disallow emptying a ComboBox.
    Object.NET
    Frameworks and Tools for .NET Developers
    --------------------------------------------------
    Ext.NET - Ext JS for ASP.NET - Examples | Twitter
    Bridge.NET - Write C#. Run JavaScript! - Live | Twitter
    --------------------------------------------------

Posting Permissions

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