Skip to content

Commit

Permalink
Ensure Previous Pagination Button is Disabled for Invalid Page
Browse files Browse the repository at this point in the history
  • Loading branch information
magicjar committed Jan 26, 2025
1 parent 616a77d commit 36028ce
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ protected virtual async Task<string> GetPageAsync(TagHelperContext context, TagH
protected virtual async Task<string> GetPreviousButtonAsync(TagHelperContext context, TagHelperOutput output)
{
var localizationKey = "PagerPrevious";
var currentPage = TagHelper.Model.CurrentPage == 1
? TagHelper.Model.CurrentPage.ToString()
: (TagHelper.Model.CurrentPage - 1).ToString();
var currentPage = TagHelper.Model.CurrentPage > 1
? (TagHelper.Model.CurrentPage - 1).ToString()
: "1";
return
"<li class=\"page-item " + (TagHelper.Model.CurrentPage == 1 ? "disabled" : "") + "\">\r\n" +
"<li class=\"page-item " + (TagHelper.Model.CurrentPage <= 1 ? "disabled" : "") + "\">\r\n" +
(await RenderAnchorTagHelperLinkHtmlAsync(context, output, currentPage, localizationKey)) + " </li>";
}

Expand Down

0 comments on commit 36028ce

Please sign in to comment.