Results 1 to 3 of 3

Thread: [6.5.2 Classic] When expanding rows with a Locked Grid, the scroll will jump around.

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium User vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Cluj, Romania
    Posts
    811

    Default [6.5.3 Classic] When expanding rows with a Locked Grid, the scroll will jump around.

    Happens in 6.5.2/3.

    Override to fix this, see the "// OVERRIDE"

    Code:
    Ext.define('overrides.view.Table', {
        override: 'Ext.view.Table',
    
    
        privates: {
    
    
            /**
             * Fix bug in Ext 6.5.2 which added optimizations to use Ext.fly but it is not reliable for activeElement
             * When expanding rows with a Locked Grid, the scroll will jump around, often to a previous focus element
             */
            saveFocusState: function() {
                var me = this,
                    store = me.dataSource,
                    actionableMode = me.actionableMode,
                    navModel = me.getNavigationModel(),
                    focusPosition = actionableMode ? me.actionPosition : navModel.getPosition(true),
                    activeElement = Ext.Element.getActiveElement(true), // OVERRIDE restore to previous version; don't use fly here, it is not reliable
                    focusCell = focusPosition && focusPosition.view === me && Ext.fly(focusPosition.getCell(true)),
                    refocusRow, refocusCol, record;
    
    
                // The navModel may return a position that is in a locked partner, so check that
                // the focusPosition's cell contains the focus before going forward.
                // The skipSaveFocusState is set by Actionables which actively control
                // focus destination. See CellEditing#activateCell.
                if (!me.skipSaveFocusState && focusCell && focusCell.contains(activeElement)) {
                    // Separate this from the instance that the nav model is using.
                    focusPosition = focusPosition.clone();
    
    
                    // While we deactivate the focused element, suspend focus processing on it.
                    activeElement.suspendFocusEvents();
    
    
                    // Suspend actionable mode.
                    // Each Actionable must silently save its state ready to resume when focus can be restored.
                    // but should only do that if the activeElement is not the cell itself, this happens when
                    // the grid is refreshed while one of the actionables is being deactivated (e.g. Calling
                    // view refresh inside CellEditor 'edit' event listener).
                    if (actionableMode && focusCell.dom !== activeElement.dom) {
                        me.suspendActionableMode();
                    }
                    // Clear position, otherwise the setPosition on the other side
                    // will be rejected as a no-op if the resumption position is logically
                    // equivalent.
                    else {
                        actionableMode = false;
                        navModel.setPosition();
                    }
    
    
                    // Do not leave the element in tht state in case refresh fails, and restoration
                    // closure not called.
                    activeElement.resumeFocusEvents();
    
    
                    // The following function will attempt to refocus back in the same mode to the same cell
                    // as it was at before based upon the previous record (if it's still in the store), or the row index.
                    return function() {
                        var all;
                        // May have changed due to reconfigure
                        store = me.dataSource;
    
    
                        // If we still have data, attempt to refocus in the same mode.
                        if (store.getCount()) {
                            all = me.all;
                            // Adjust expectations of where we are able to refocus according to what kind of destruction
                            // might have been wrought on this view's DOM during focus save.
                            refocusRow = Math.min(Math.max(focusPosition.rowIdx, all.startIndex), all.endIndex);
                            refocusCol = Math.min(focusPosition.colIdx, me.getVisibleColumnManager().getColumns().length - 1);
                            record = focusPosition.record;
    
    
                            focusPosition = new Ext.grid.CellContext(me).setPosition(
                                    record && store.contains(record) && !record.isCollapsedPlaceholder ? record : refocusRow, refocusCol
                            );
    
    
                            // Maybe there are no cells. eg: all groups collapsed.
                            if (focusPosition.getCell(true)) {
                                if (actionableMode && !store.isExpandingOrCollapsing) {
                                    me.resumeActionableMode(focusPosition);
                                } else {
                                    // Pass "preventNavigation" as true so that that does not cause selection.
                                    navModel.setPosition(focusPosition, null, null, null, true);
    
    
                                    if (!navModel.getPosition()) {
                                        focusPosition.column.focus();
                                    }
                                }
                            }
                        }
                        // No rows - focus associated column header
                        else {
                            focusPosition.column.focus();
                        }
                    };
                }
                return Ext.emptyFn;
            }
    }
    Github https://github.com/vadimpopa
    Blogging @ : http://vadimpopa.com
    Twitter: @vadimvpopa

  2. #2
    Sencha Premium User vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Cluj, Romania
    Posts
    811

    Default

    bump
    Github https://github.com/vadimpopa
    Blogging @ : http://vadimpopa.com
    Twitter: @vadimvpopa

  3. #3
    Sencha Premium User vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Cluj, Romania
    Posts
    811

    Default

    bump
    Github https://github.com/vadimpopa
    Blogging @ : http://vadimpopa.com
    Twitter: @vadimvpopa

Similar Threads

  1. [CLOSED] Grouped grid scroll jump on cell edit
    By dansmm in forum Ext 5: Bugs
    Replies: 1
    Last Post: 23 Nov 2015, 8:09 AM
  2. Replies: 5
    Last Post: 11 Jun 2015, 3:36 PM
  3. Replies: 3
    Last Post: 23 Oct 2014, 4:48 AM
  4. Replies: 1
    Last Post: 30 Mar 2011, 11:07 PM
  5. About Grid: Expanding rows
    By ozonenetwork in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 4 Aug 2008, 11:44 PM

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
  •