Skip to content

Commit eec9266

Browse files
authored
Merge pull request #66 from nirupama-dev/fe-pagination-retain-back
Fe pagination retain back: bug fixed on pagination
2 parents 778b2a2 + b8045e9 commit eec9266

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/scheduler/vertex/ListVertexScheduler.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ function ListVertexScheduler({
195195
const hasListChanged = previousScheduleList.current !== vertexScheduleList;
196196
const hasNextPageTokenChanged =
197197
previousNextPageToken.current !== nextPageToken;
198-
198+
// Reset pagination variables only if the list has changed or next page token has changed
199+
// or if the resetToCurrentPage is true.
199200
if (resetToCurrentPage || (hasListChanged && hasNextPageTokenChanged)) {
200201
setPaginationVariables();
201202

@@ -213,7 +214,6 @@ function ListVertexScheduler({
213214
const setPaginationVariables = () => {
214215
let updatedPageTokenList = [...pageTokenList];
215216
let resetFlag = resetToCurrentPage;
216-
217217
if (fetchPreviousPage) {
218218
// True only in case of clicking for previous page
219219
if (updatedPageTokenList.length > 0) {
@@ -243,8 +243,11 @@ function ListVertexScheduler({
243243
}
244244
}
245245
setCanNextPage(hasNextPage);
246-
const hasPreviousPage = updatedPageTokenList.length > 1; // true only if not in first page
246+
const hasPreviousPage = hasNextPage
247+
? updatedPageTokenList.length > 1
248+
: updatedPageTokenList.length > 0; // hasPreviousPage is true if there are more than 1 tokens in the list, which means there is a previous page available.
247249
setCanPreviousPage(hasPreviousPage); // false only on first page
250+
248251
setPageTokenList([...updatedPageTokenList]); // set the updated token list after pagination
249252
let startIndex = 1;
250253
if (hasPreviousPage) {

0 commit comments

Comments
 (0)