ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Adding a row changes the selected cell with ui-grid-cellNav

Open ahocquet opened this issue 10 years ago • 4 comments

Hi,

I've spotted a bug when I use ui-grid-cellNav and try to add a new element to the data. This bug only happens when the new element is added on top of the grid, and when it's done, the class "ui-grid-cell-focus" doesn't move with its matching cell and thus highlights the wrong element.

Check this plnkr : http://plnkr.co/edit/MFywMvsLDRvK8PMq1I6m It's already sorted by ID.

  1. Select "Bender Jefferson" cell
  2. Click Add row - it will duplicated the first entry
  3. The class "ui-grid-cell-focus" remained on the same cell so its now highlighting the wrong element.
  4. Click on "Get current focused cell" and check that thw row number doesn't match.

ahocquet avatar Nov 20 '15 08:11 ahocquet

I've found a way to fix this bug, see this PR : https://github.com/angular-ui/ui-grid/pull/4740

ahocquet avatar Nov 20 '15 11:11 ahocquet

I'm having the same issue with adding row causing me to lost focus only when the virtualization threshold kicks in.

dpinho17 avatar Dec 01 '15 15:12 dpinho17

I also found this problem, the fix provided by @ahocquet works, but it is quite slow, so I decided not to include it in my own build of ui-grid. Instead, I worked around the problem by broadcasting CELL_NAV_EVENT in my page's controller code after I have refreshed list of rows that might caused insertion of rows above the currently selected cell:

        // some code that alters rows array of gridOpitons
        $timeout(function() {
            $scope.$broadcast(uiGridCellNavConstants.CELL_NAV_EVENT);
        });

This way it works quite smoothly.

asharayev avatar Jan 17 '16 22:01 asharayev

@ahocquet is the issue still open

sumitgsh avatar May 10 '21 19:05 sumitgsh