Skip to content

Commit

Permalink
fix: Scroll problem when cell is focused
Browse files Browse the repository at this point in the history
  • Loading branch information
netchampfaris committed Mar 30, 2019
1 parent 0f44a51 commit 1845adc
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/cellmanager.js
Expand Up @@ -212,7 +212,9 @@ export default class CellManager {
}

focusCell($cell, {
skipClearSelection = 0
skipClearSelection = 0,
skipDOMFocus = 0,
skipScrollToCell = 0
} = {}) {
if (!$cell) return;

Expand All @@ -232,7 +234,9 @@ export default class CellManager {
return;
}

this.scrollToCell($cell);
if (!skipScrollToCell) {
this.scrollToCell($cell);
}

this.deactivateEditing();
if (!skipClearSelection) {
Expand All @@ -246,8 +250,10 @@ export default class CellManager {
this.$focusedCell = $cell;
$cell.classList.add('dt-cell--focus');

// so that keyboard nav works
$cell.focus();
if (!skipDOMFocus) {
// so that keyboard nav works
$cell.focus();
}

this.highlightRowColumnHeader($cell);
}
Expand Down Expand Up @@ -313,11 +319,15 @@ export default class CellManager {
const $cell = this.getCell$(colIndex, rowIndex);

if (!$cell) return;
// this function is called after selectAreaOnClusterChanged,
// 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
this.focusCell($cell, {
skipClearSelection: 1
skipClearSelection: 1,
skipDOMFocus: 1,
skipScrollToCell: 1
});
}

Expand Down

0 comments on commit 1845adc

Please sign in to comment.