1

I am working with the Sencha EXT JS app on version 7.2 and we found the following scenario:

  • Click on the dropdown and select a value
  • Click "done"
  • Click on the dropdown and select another value
  • Click "cancel"
  • Click on the dropdown
  • Verify the invalid value selected

There is a sencha fiddle to help to reproduce this behavior:
https://fiddle.sencha.com/#view/editor&fiddle/3704

Thank you!

2 Answers2

1

Looks like to be standard feature (not a bug) ;) Anyway, to fix/change behavior for all the comboboxes use the following override:

Ext.define('overrides.field.ComboBox', {
    override: 'Ext.field.ComboBox',
    onExpandTap: function() {
        this.getPicker().setValue(this.getValue());
        this.callParent();
    }
});

To do the same for single combobox:

{
    picker: 'edge',
    xtype: 'combobox',
    valueField: 'id',
    displayField: 'description',
    queryMode: 'local',
    store: 'optionsStore',
    listeners: {
        // Add this..
        expand: function(field) {
            field.getPicker().setValue(field.getValue());
        }
    }
}
Arthur Rubens
  • 4,626
  • 1
  • 8
  • 11
  • 1
    I thought that might be the default behavior, but even when we refresh the page, the value selected is not correct. For the scenario of our projects, We think that it makes sense to always select the current value set in this field. We create an override for this file, but we will try to use what you suggested, it is more simple than ours. Thanks again for your help! – Renato Carvalho Jun 28 '20 at 21:19
  • 1
    Actually, I think it is specific to our scenario. I posted above what we did to fix this behavior. – Renato Carvalho Jun 29 '20 at 12:28
1

For our scenario, the problem is when we refreshed the page. Using your override suggestion, only when I opened on the second time the value is selected correctly.

So we are using the following override to fix this behavior:

Ext.define('Ext.override.field.Select', {
    override: 'Ext.field.Select',
    updatePickerValue: function (picker, value) {
        if (!value) value = this.getValue();
        picker.setValue(value);
    }
});

It is almost the same, but we are overriding the updatePickerValue method.

Thanks for you help!

  • Renato Carvalho