From b142a1076d4551ab373dd293050339fbdd2d6405 Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Tue, 21 Apr 2026 12:36:40 +0700 Subject: [PATCH] Keep validation dialog in sync after removing an item Recompute filtered, sorted, and paginated validation state after a request is removed from the pending list.\nAdjust next-item selection so the dialog advances only when a valid next item exists, avoiding wraparound to stale entries. --- app/Views/shared/script_validation.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/Views/shared/script_validation.php b/app/Views/shared/script_validation.php index c547085..f44cd02 100644 --- a/app/Views/shared/script_validation.php +++ b/app/Views/shared/script_validation.php @@ -273,9 +273,17 @@ document.addEventListener('alpine:init', () => { item => item.SP_ACCESSNUMBER !== accessnumber ); + this.computeUnvalidatedFiltered(); + this.computeUnvalidatedSorted(); + this.computeUnvalidatedTotalPages(); + if (this.currentPage > this.unvalidatedTotalPages) { + this.currentPage = this.unvalidatedTotalPages; + } + this.computeUnvalidatedPaginated(); + const filteredLength = this.unvalidatedFiltered.length; - if (filteredLength > 0) { - const nextIndex = Math.min(this.currentIndex, filteredLength - 1); + if (filteredLength > 0 && this.currentIndex < filteredLength) { + const nextIndex = this.currentIndex; this.closeValDialog(); setTimeout(() => this.openValDialogByIndex(nextIndex), 50); } else {