From 647a902e9f941b31b8dfe1c04ab281aaf6e9aeb3 Mon Sep 17 00:00:00 2001 From: pa Date: Wed, 18 Mar 2026 21:03:23 +0900 Subject: [PATCH] fix: reset page index when total page count shrinks below current page --- .../PreviousInstancesListDialog.vue | 1 + src/components/ui/data-table/DataTableLayout.vue | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue b/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue index 48c4c053..e1fe2921 100644 --- a/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue +++ b/src/components/dialogs/PreviousInstancesDialog/PreviousInstancesListDialog.vue @@ -251,6 +251,7 @@ const D = previousInstancesListDialog.value; if (currentId.value !== D.lastId) { table.setPageIndex(0); + pageIndex.value = 0; D.lastId = currentId.value; } if (props.variant === 'user') { diff --git a/src/components/ui/data-table/DataTableLayout.vue b/src/components/ui/data-table/DataTableLayout.vue index 9acf94bd..e44943c2 100644 --- a/src/components/ui/data-table/DataTableLayout.vue +++ b/src/components/ui/data-table/DataTableLayout.vue @@ -629,6 +629,19 @@ } }); + // When the total page count shrinks below the current page + // jump to the last available page + watch( + () => props.table.getPageCount?.(), + (pageCount) => { + if (pageCount == null || pageCount <= 0) return; + const pageIndex = props.table.getState?.().pagination?.pageIndex ?? 0; + if (pageIndex >= pageCount) { + props.table.setPageIndex(pageCount - 1); + } + } + ); + watch([currentPage, pageSizeProxy], async () => { await nextTick(); if (tableScrollRef.value) {