Pagination changer - #106
Merged
Merged
Conversation
- PageLinkGenerator now uses PaginationState for richer context. - Redesigned page size changer with customizable templates. - Added ChangerId for improved accessibility. - PaginationState includes PageSize, IsFirstPage, IsLastPage. - Updated href logic and page size change handling. - Refreshed tests and samples for new API and features.
…page changer from news page on sample since it's SSR page
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends BitPagination with an optional page-size changer (ShowChanger) implemented via BitDropdown, and updates the PageLinkGenerator API to accept a richer PaginationState (now including PageSize). It also updates docs, stories, samples, and tests to demonstrate and validate the new behavior, including SSR/interactive render-mode guidance.
Changes:
- Added a page-size changer UI to
BitPagination(dropdown-based) plus related parameters (PageSize*,Changer*,PageSizeLabelTemplate). - Updated
PaginationStateand changedPageLinkGeneratorfromFunc<int, string>toFunc<PaginationState, string>. - Updated documentation, stories, samples, and tests to reflect the new API and feature set (including interactive-vs-SSR notes).
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/BitBlazor.Test/Components/Pagination/BitPaginationTest.Rendering.razor | Updates rendering expectations and adds markup tests for the new changer UI. |
| tests/BitBlazor.Test/Components/Pagination/BitPaginationTest.Behaviors.cs | Updates PageLinkGenerator signature usage and adds behavior tests for page-size changing + changer accessibility/id stability. |
| tests/BitBlazor.Test/Components/Dropdown/BitDropdownTest.Behaviors.cs | Adds a behavior test asserting the dropdown closes when an item is clicked. |
| stories/BitBlazor.Stories/Components/Stories/Components/BitPagination.stories.razor | Adds Storybook args and stories demonstrating page-size changer usage. |
| src/BitBlazor/Components/Pagination/PaginationState.cs | Extends PaginationState to include PageSize. |
| src/BitBlazor/Components/Pagination/BitPagination.razor.cs | Implements new changer parameters/state and updates URL generation to use PaginationState. |
| src/BitBlazor/Components/Pagination/BitPagination.razor | Renders the new page-size changer dropdown UI when enabled. |
| src/BitBlazor/Components/Dropdown/BitDropdownItem.razor.cs | Closes the dropdown after an item click (used by pagination changer). |
| src/BitBlazor/Components/Dropdown/BitDropdown.razor.cs | Adds/organizes closing behavior and clarifies interactive render-mode requirements. |
| samples/BitBlazor.Sample/BitBlazor.Sample/Services/PraticheService.cs | Adds pageSize support to the sample data service. |
| samples/BitBlazor.Sample/BitBlazor.Sample/Services/NewsService.cs | Adds pageSize support to the sample data service. |
| samples/BitBlazor.Sample/BitBlazor.Sample/Services/IPraticheService.cs | Updates interface to accept pageSize. |
| samples/BitBlazor.Sample/BitBlazor.Sample/Services/INewsService.cs | Updates interface to accept pageSize. |
| samples/BitBlazor.Sample/BitBlazor.Sample/Components/Pages/Pratiche.razor | Demonstrates ShowChanger usage and reload behavior on page-size changes. |
| samples/BitBlazor.Sample/BitBlazor.Sample/Components/Pages/News.razor | Updates to new PageLinkGenerator signature and interactive binding pattern. |
| docs/components/pagination.md | Documents the new changer feature and updated PageLinkGenerator/SSR guidance. |
| docs/components/dropdown.md | Documents interactive render-mode requirement, including indirect usage via pagination changer. |
Suppressed comments (1)
src/BitBlazor/Components/Pagination/BitPagination.razor:42
- When
Disabledis true, the page-size dropdown items should also be disabled; otherwise the page size can still change via keyboard/mouse even though the pagination is disabled.
<BitDropdownItem Active="@(state.PageSize == pageSize)" Href="@GetPageSizeHref(pageSize)" OnClick="@(() => ClickPageSizeItemAsync(pageSize))">
<span>@RenderPageSizeLabel(pageSize)</span>
</BitDropdownItem>
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request significantly enhances the documentation and sample usage of the
BitPaginationcomponent, introducing and documenting a new page size changer feature (ShowChanger) and updating thePageLinkGeneratorAPI to support more flexible navigation scenarios. The changes clarify SSR (server-side rendering) compatibility, improve accessibility, and provide comprehensive usage examples for the new features.Key changes include:
New Page Size Changer Feature
Added documentation and usage examples for the page size changer (
ShowChanger), allowing users to select the number of items per page via a dropdown. This includes new parameters such asPageSize,PageSizeOptions,ChangerId, andPageSizeLabelTemplate, as well as guidance on two-way binding and event callbacks for page size changes. [1] [2] [3] [4] [5] [6]Updated accessibility and generated HTML/CSS documentation to cover the new dropdown, including keyboard accessibility and custom ID assignment for the changer. [1] [2]
PageLinkGeneratorAPI ImprovementsPageLinkGeneratorparameter to accept aPaginationStateobject (containing both current page and page size) instead of just the page number, enabling URLs that reflect both pagination and page size. All related documentation, code samples, and parameter tables have been updated accordingly. [1] [2] [3] [4] [5]SSR and Render Mode Clarifications
ShowChanger), which usesBitDropdown, only works in interactive render modes and not in static SSR. Documentation now explains the fallback behavior and links to related dropdown documentation. [1] [2] [3]Sample and Usage Updates
News.razor) to reflect the newPageLinkGeneratorsignature and to demonstrate two-way binding with page and page size. Added new examples for custom label templates, custom IDs, and SSR-compatible URLs. [1] [2] [3] [4]Accessibility and Progressive Enhancement
These updates make the
BitPaginationcomponent more flexible, accessible, and easier to integrate in both interactive and SSR Blazor applications.