Results 1 to 5 of 5

Thread: Focus jump in RowEditing plugin in Ext.window

  1. #1
    Sencha User
    Join Date
    Nov 2009
    Posts
    10
    Vote Rating
    0
      0  

    Default Answered: Focus jump in RowEditing plugin in Ext.window

    Hi,

    While I was working on something, I encountered a strange problem. I searched forums but couldn't find anything similar to this issue, so here it is. Ext version is 4.1.1. I don't think I had this problem with 4.0.7 but not 100% sure.

    I have an editable grid with rowediting plugin, which is inside of Ext.Window.
    I use numberfield as editor for 2 columns and have minValue, minLength, maxLength, enforceMaxLength set.
    When I start editing a row, and if a field becomes valid from invalid, the focus is lost from the field (I think it is focusing window). This prevents me using 'Enter' key to update the row, or use 'Tab' key to navigate to other editor fields. When editable grid is inside a container that is not floating (that is, other than Ext.Window), it acts as normal.

    To reproduce try this code. Once grid inside window shows, click top button to add a row, then start editing.
    minLength and maxLength are set to 9. so as you start editing, you get red border, tooltip indicating the field is invalid. As you type 9th number, invalid marks are gone, but as well as the focus.

    Not sure this is bug or something in my code. (I tried to make it simple. This is part of more complex app)

    Thanks in advance.

    Code:
            Ext.define('BarcodeRange', {
                extend: 'Ext.data.Model',
                fields: [ 'start', 'end', { name: 'count', type: 'int' } ]
            });
    
    
            Ext.define('BarcodeRanges', {
                extend: 'Ext.data.Store',
                model: 'BarcodeRange'
            });
    
    
            Ext.onReady(function() {
                var bGrid = Ext.create('widget.grid', {
                    columns: [
                        {
                            header: 'Start', dataIndex: 'start', flex: 1, soartable: false,
                            editor: {
                                xtype: 'numberfield', itemId: 'startBarcode', maxLength: 9, enforceMaxLength: true, minLength: 9, validateOnChange: false, tabIndex: 1,
                                hideTrigger: true, minValue: 0, allowDecimals: false
                            }
                        },
                        {
                            header: 'End', dataIndex: 'end', flex: 1, soartable: false,
                            editor: {
                                xtype: 'numberfield', itemId: 'endBarcode', maxLength: 9, enforceMaxLength: true, minLength: 9, validateOnChange: false, tabIndex: 1,
                                hideTrigger: true, minValue: 0, allowDecimals: false
                            }
                        },
                        { header: 'Count', dataIndex: 'count', width: 45, soartable: false, align: 'right' },
                        {
                            xtype  : 'actioncolumn', header : 'Cancel', width  : 50, align  : 'center', soartable: false,
                            items  : [
                                {
                                    icon: '/imgs/delete_icon.png', iconCls: 'action-shipment-edit', handler: function(grid, rix, cix) {
                                        grid.getStore().removeAt(rix);
                                    }
                                }
                            ]
                        }
                    ],
    
    
                    dockedItems : [
                        {
                            xtype: 'toolbar', dock: 'top',
                            items: [
                                {
                                    xtype: 'button', text: 'Add Barcode Sequence', icon: '/imgs/add.png',
                                    handler: function(btn, e) {
                                        var newBarcodeRange = Ext.create('BarcodeRange');
    
    
                                        btn.up('grid').getStore().add(newBarcodeRange);
                                        btn.up('grid').getPlugin('rowEditor').startEdit(newBarcodeRange, 0);
                                    }
                                }
                            ]
                        },
                        {
                            xtype: 'toolbar', dock: 'bottom',
                            items: [
                                '->',
                                {
                                    xtype: 'numberfield', itemId: 'partialBarcode', fieldLabel: 'Partial (Optional)',
                                    width: 200, allowDecimals: false, hideTrigger: true,
                                    maxLength: 9, enforceMaxLength: true, minLength: 9, minValue: 0,
                                    listeners: {
                                        errorchange: function(comp, error, eopts) {
                                            var saveButton = comp.up('window').down('button[action=Save]');
                                            if (error === "") {
                                                saveButton.enable();
                                            } else {
                                                saveButton.disable();
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    ],
    
    
                    plugins: [
                        { ptype: 'rowediting', pluginId: 'rowEditor', clicksToEdit: 2 }
                    ]
                });
    
    
                var win = Ext.create('widget.window', {
                    title       : 'Barcodes Ranges',
                    width       : 300,
                    height      : 300,
                    closeAction : 'hide',
                    closable    : false,
                    modal       : true,
                    layout      : 'fit',
                    buttonAlign : 'right',
                    buttons     : [ { xtype: 'button', action: 'Save', text: 'Save', handler: function() { /*me.saveBarcodes*/ } } ],
                    items       : [ bGrid]
                });
    
    
                win.show();
            });

  2. This was a bug that should be fixed in a later release. Plus, perf is much greater in 4.1

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Answers
    3931
    Vote Rating
    1271
      0  

    Default

    This was a bug that should be fixed in a later release. Plus, perf is much greater in 4.1
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Nov 2009
    Posts
    10
    Vote Rating
    0
      0  

    Default

    Thanks Mitchell, but is there any temporary fix for this? I'm really pushing for 4.1 upgrade at work (yeah, performance is a lot better in 4.1), but users will be really annoyed if I do nothing about this.

  5. #4
    Sencha User
    Join Date
    Nov 2009
    Posts
    10
    Vote Rating
    0
      0  

    Default

    For the record, I had to use focus(false, 20) to work around this problem.
    Code:
    {
        header: 'Start', dataIndex: 'start', flex: 1, soartable: false,
        editor: {
            xtype: 'numberfield', itemId: 'startBarcode', maxLength: 9, enforceMaxLength: true, 
            minLength: 9, vtype: '',
             minLengthText:'Required length is 9 digits',maxLengthText:'Required length is 9 digits',
             hideTrigger: true, keyNavEnabled: false, mouseWheelEnabled: false, minValue: 0, allowDecimals: false,
             listeners: {
                   errorchange: function(comp, error, eopts) {
                      comp.focus(false, 50);
                   }
             }
        }
    },
    {
        header: 'End', dataIndex: 'end', flex: 1, soartable: false,
        editor: {
             xtype: 'numberfield', itemId: 'endBarcode', maxLength: 9, enforceMaxLength: true, 
             minLength: 9, vtype: '', hideTrigger: true,
             minLengthText:'Required length is 9 digits',maxLengthText:'Required length is 9 digits',
             keyNavEnabled: false, mouseWheelEnabled: false, minValue: 0, allowDecimals: false,
            listeners: {
                errorchange: function(comp, error, eopts) {
                    comp.focus(false, 50);
                }
            }
        }
    }
    Also I had another focus problem if I add a record and used startEdit in window's show event. (it would focus window instead of the editor. I could see that editor field was focused but then the focus jumps to the window. I think window uses some kind of deferred focus) I also worked around this using Ext.defer

  6. #5
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    1
    Vote Rating
    0
      0  

    Default

    Hi,

    I am also experiencing this issue and am running on version 4.1.1. Could you please provide the ticket number so I may track when it is complete?

    Thanks.

Tags for this Thread

Posting Permissions

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