Skip to content

Commit

Permalink
Calls updateFocus() inside a requestAnimationFrame()
Browse files Browse the repository at this point in the history
  • Loading branch information
ffknob committed Nov 18, 2019
1 parent 1d1c7e7 commit fe3fc64
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/datagrid/data_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ function createKeyDownHandler(
? focusedCell[1]
: newPageRowCount - 1;
setFocusedCell([focusedCell[0], rowIndex]);
// TODO: Probably not the right point to call this
updateFocus([focusedCell[0], rowIndex]);
requestAnimationFrame(() => updateFocus([focusedCell[0], rowIndex]));
}
}
} else if (keyCode === keyCodes.PAGE_UP) {
Expand All @@ -344,9 +343,13 @@ function createKeyDownHandler(
if (pageIndex > 0) {
props.pagination!.pageIndex = pageIndex - 1;
props.pagination.onChangePage(props.pagination.pageIndex);
const newPageRowCount = computeVisibleRows(props);
const rowIndex =
focusedCell[1] < newPageRowCount
? focusedCell[1]
: newPageRowCount - 1;
setFocusedCell([focusedCell[0], focusedCell[1]]);
// TODO: Probably not the right point to call this
updateFocus([focusedCell[0], focusedCell[1]]);
requestAnimationFrame(() => updateFocus([focusedCell[0], rowIndex]));
}
}
} else if (keyCode === (ctrlKey && keyCodes.END)) {
Expand Down

0 comments on commit fe3fc64

Please sign in to comment.