From 8c63ccadf9cc55e8b655d7202e0b073fdbe64618 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Tue, 8 Mar 2022 08:43:05 -0800 Subject: [PATCH] Re-add datagrid pagination checks --- src/components/datagrid/utils/focus.ts | 4 ++-- src/components/datagrid/utils/ref.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/datagrid/utils/focus.ts b/src/components/datagrid/utils/focus.ts index 910e067a70a5..06c3145e3434 100644 --- a/src/components/datagrid/utils/focus.ts +++ b/src/components/datagrid/utils/focus.ts @@ -215,7 +215,7 @@ export const createKeyDownHandler = ({ setFocusedCell([x + 1, y]); } } else if (key === keys.PAGE_DOWN) { - if (pagination) { + if (pagination && pagination.pageSize > 0) { event.preventDefault(); const pageSize = pagination.pageSize; const pageCount = Math.ceil(rowCount / pageSize); @@ -226,7 +226,7 @@ export const createKeyDownHandler = ({ setFocusedCell([focusedCell[0], 0]); } } else if (key === keys.PAGE_UP) { - if (pagination) { + if (pagination && pagination.pageSize > 0) { event.preventDefault(); const pageIndex = pagination.pageIndex; if (pageIndex > 0) { diff --git a/src/components/datagrid/utils/ref.ts b/src/components/datagrid/utils/ref.ts index 88aebb8eb8de..5c4d6a0085ea 100644 --- a/src/components/datagrid/utils/ref.ts +++ b/src/components/datagrid/utils/ref.ts @@ -135,7 +135,7 @@ export const useSortPageCheck = ( : rowIndex; // Account for pagination - if (pagination) { + if (pagination && pagination.pageSize > 0) { const pageIndex = Math.floor(visibleRowIndex / pagination.pageSize); // If the targeted row is on a different page than the current page, // we should automatically navigate the user to the correct page