ComboBox in IE 10/11 be focus [closed]

2019-09-21 20:32发布

问题:

Ext version: 5.1.0.107 Browser: IE 10/11

While i create a ComboBox with a value, the ComboBox will be focus after it was rendered.

demo: http://ift.tt/1326fZR

How can i resolve this problem?

回答1:

Solution you can find here:

https://www.sencha.com/forum/showthread.php?296103-ComboBox-in-IE-10-11-be-focus

Ext.define('Ext.overrides.form.field.ComboBox', {
     override: 'Ext.form.field.ComboBox',

     // OVERRIDE
     checkChangeEvents : Ext.isIE ? 
                    ['change', 'propertychange', 'keyup'] :
                    ['change', 'input', 'textInput', 'keyup', 'dragdrop']
});


回答2:

For me it worked after I have override something more.

Ext.override(Ext.form.field.Base, {
    initEvents: function() {
        var me = this,
        inputEl = me.inputEl,
            onFieldMutation = me.onFieldMutation,
            events = me.checkChangeEvents,
            len = events.length,
            i, event;
        if (inputEl) {
            me.mon(inputEl, Ext.supports.SpecialKeyDownRepeat ? 'keydown' : 'keypress', me.fireKey, me);
            for (i = 0; i < len; ++i) {
                event = events[i];
                if (event === 'propertychange') {
                    me.usesPropertychange = true;
                }
                if (event === 'textInput') {
                    me.usesTextInput = true;
                }
                me.mon(inputEl, event, onFieldMutation, me);
            }
        }
        me.callParent();
    },

    bindPropertyChange: function(active) {
        var method = active ? 'resumeEvent' : 'suspendEvent',
            inputEl = this.inputEl;
        if (this.usesPropertychange) {
            inputEl[method]('propertychange');
        }
        if (this.usesTextInput) {
            inputEl[method]('textInput');
        }
    }
});

This part is copied from version 5.1.1.451 where bug is already fixed.