diff --git a/src/cellmanager.js b/src/cellmanager.js index 8275bfd..0f20473 100644 --- a/src/cellmanager.js +++ b/src/cellmanager.js @@ -33,6 +33,7 @@ export default class CellManager { this.bindKeyboardSelection(); this.bindCopyCellContents(); this.bindMouseEvents(); + this.bindWheelEvents(); this.bindTreeEvents(); } @@ -81,6 +82,7 @@ export default class CellManager { } this.focusCell($cell); + sessionStorage.setItem('dt-last-nav-method', 'key'); return true; }; @@ -189,6 +191,12 @@ export default class CellManager { $.on(this.bodyScrollable, 'mousemove', '.dt-cell', throttle(selectArea, 50)); } + bindWheelEvents() { + $.on(this.bodyScrollable, 'wheel', (e) => { + sessionStorage.setItem('dt-last-nav-method', 'scroll'); + }); + } + bindTreeEvents() { $.on(this.bodyScrollable, 'click', '.dt-tree-node__toggle', (e, $toggle) => { const $cell = $.closest('.dt-cell', $toggle); @@ -313,11 +321,13 @@ export default class CellManager { // this function is called after hyperlist renders the rows after scroll, // focusCell calls clearSelection which resets the area selection // so a flag to skip it - // we also skip DOM focus and scroll to cell - // because it fights with the user scroll + // we skip scroll to cell + // and also skip DOM focus (if user is scrolling) because it fights with the user scroll + const skipDOMFocus = sessionStorage.getItem('dt-last-nav-method') !== 'key'; + this.focusCell($cell, { + skipDOMFocus, skipClearSelection: 1, - skipDOMFocus: 1, skipScrollToCell: 1 }); } @@ -714,6 +724,7 @@ export default class CellManager { } this.focusCell($cell); + sessionStorage.setItem('dt-last-nav-method', 'key'); return true; }