From 66e69e750e900a7e196e6dec1abc0d601699e7bc Mon Sep 17 00:00:00 2001 From: Istiak Tridip <13367189+istiak-tridip@users.noreply.github.com> Date: Thu, 29 Jan 2026 20:41:59 +0600 Subject: [PATCH] feat: fall back to index navigation when items fit on one page --- src/util/ButtonNavigator.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util/ButtonNavigator.cpp b/src/util/ButtonNavigator.cpp index 585de13f..d9844138 100644 --- a/src/util/ButtonNavigator.cpp +++ b/src/util/ButtonNavigator.cpp @@ -90,6 +90,11 @@ int ButtonNavigator::previousIndex(const int currentIndex, const int totalItems) int ButtonNavigator::nextPageIndex(const int currentIndex, const int totalItems, const int itemsPerPage) { if (totalItems <= 0 || itemsPerPage <= 0) return 0; + // When items fit on one page, use index navigation instead + if (totalItems <= itemsPerPage) { + return nextIndex(currentIndex, totalItems); + } + const int lastPageIndex = (totalItems - 1) / itemsPerPage; const int currentPageIndex = currentIndex / itemsPerPage; @@ -103,6 +108,11 @@ int ButtonNavigator::nextPageIndex(const int currentIndex, const int totalItems, int ButtonNavigator::previousPageIndex(const int currentIndex, const int totalItems, const int itemsPerPage) { if (totalItems <= 0 || itemsPerPage <= 0) return 0; + // When items fit on one page, use index navigation instead + if (totalItems <= itemsPerPage) { + return previousIndex(currentIndex, totalItems); + } + const int lastPageIndex = (totalItems - 1) / itemsPerPage; const int currentPageIndex = currentIndex / itemsPerPage;