Skip to content

Commit

Permalink
handle more corner cases in displayNavigationButton
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed May 31, 2024
1 parent fba4a7f commit b073d0c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/views/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ function displayNavigationButton(int $current_page_number, int $total_pages, str
$link_content = htmlspecialchars($is_left ? "<" : ">");
$className = "page-item";

if (($current_page_number <= 1 && $is_left) || ($current_page_number >= $total_pages && !$is_left)) {
if (($current_page_number > $total_pages) || // invalid page number
($current_page_number < 1) || // invalid page number
($current_page_number === 1 && $is_left) || // first page
($current_page_number === $total_pages && !$is_left) // last page
) {
$className .= " disabled";
}

Expand Down

0 comments on commit b073d0c

Please sign in to comment.