Skip to content

Commit

Permalink
Fix: Keep focused cell position, taking account of changes in the tab…
Browse files Browse the repository at this point in the history
…le data structure

Merge pull request #31 from StevenLiekens/fix-retain-focus
  • Loading branch information
Allan Jardine committed Apr 6, 2017
2 parents 66a4551 + d8361d4 commit 0e007d0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions js/dataTables.keyTable.js
Expand Up @@ -249,7 +249,10 @@ $.extend( KeyTable.prototype, {
var lastFocus = that.s.lastFocus;

if ( lastFocus && lastFocus.node && $(lastFocus.node).closest('body') === document.body ) {
var relative = that.s.lastFocus.relative;
var relative = {
row: dt.rows( { page: 'current' } ).indexes().indexOf( lastFocus.cell.index().row ),
column: lastFocus.cell.index().column
}
var info = dt.page.info();
var row = relative.row + info.start;

Expand Down Expand Up @@ -524,11 +527,7 @@ $.extend( KeyTable.prototype, {
// Event and finish
this.s.lastFocus = {
cell: cell,
node: cell.node(),
relative: {
row: dt.rows( { page: 'current' } ).indexes().indexOf( cell.index().row ),
column: cell.index().column
}
node: cell.node()
};

this._emitEvent( 'key-focus', [ this.s.dt, cell, originalEvent || null ] );
Expand Down

0 comments on commit 0e007d0

Please sign in to comment.