Skip to content

Fix API for QuickGrid#67733

Open
dariatiurina wants to merge 4 commits into
dotnet:mainfrom
dariatiurina:66830-quickgrid
Open

Fix API for QuickGrid#67733
dariatiurina wants to merge 4 commits into
dotnet:mainfrom
dariatiurina:66830-quickgrid

Conversation

@dariatiurina

@dariatiurina dariatiurina commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fix API for QuickGrid

Summary

Adjusts the unshipped QuickGrid URL-state API to match what was approved in API review for #66830: the QueryParameterNamePrefix string parameter is replaced with a new sealed QueryParameterNameOptions class that lets callers control each query parameter name independently.

Changes

  • New QueryParameterNameOptions type — a sealed class with a primary constructor QueryParameterNameOptions(string prefix = "") and three settable properties: Sort, Direction, and Page, defaulting to "{prefix}sort", "{prefix}direction", and "{prefix}page".
  • QuickGrid<TGridItem> parameter changed[Parameter] public string QueryParameterNamePrefix is replaced by [Parameter] public QueryParameterNameOptions? QueryParameterNameOptions. When null, the query parameters default to sort, direction, and page.
  • Direction query parameter renamed — the sort-direction parameter changed from order to direction (the default for QueryParameterNameOptions.Direction).
  • PublicAPI.Unshipped.txt updated to remove the QueryParameterNamePrefix entries and add the new type and parameter.
  • Test assets and E2E tests updated to the new API and parameter names.

Details

Previously the component owned the naming scheme: an empty prefix produced sort/order/page, and a non-empty prefix such as "products" produced products_sort/products_order/products_page (the component inserted the _ separator). The approved design moves that control to the caller — the prefix now includes its own separator (e.g. new("products_") produces products_sort, products_direction, products_page), and each name can also be set individually via the Sort/Direction/Page properties. This keeps the multi-grid scenario working (unique names per grid to avoid URL conflicts) while giving callers full control over each parameter name.

Testing

Existing QuickGrid E2E suites were updated to the new API:

  • QuickGridNoInteractivityTest, QuickGridInteractiveTest, and QuickGridInteractiveCompatTest — updated sort-direction URL assertions from order= to direction=.
  • Test asset pages (QuickGridComponent.razor, QuickGridInteractive.razor) — updated to pass QueryParameterNameOptions with an explicit prefix (e.g. new("QuickGrid2_"), new("people_")) in place of QueryParameterNamePrefix.

Breaking Changes

These affect the unshipped (preview) API introduced in #65451, not a released API:

  • QuickGrid<TGridItem>.QueryParameterNamePrefix is removed; use QueryParameterNameOptions instead.
  • The default sort-direction query parameter name changed from order to direction.

Fixes #66830

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the unshipped QuickGrid URL-state API to match the approved design by replacing the single prefix-based parameter with a new options object that allows callers to control each query parameter name, and by renaming the default sort-direction query key from order to direction.

Changes:

  • Introduces QueryParameterNameOptions (prefix-based defaults + per-parameter overrides for sort/direction/page).
  • Replaces QuickGrid<TGridItem>.QueryParameterNamePrefix with QuickGrid<TGridItem>.QueryParameterNameOptions.
  • Updates test assets and E2E assertions to use the new API and direction= query parameter.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QueryParameterNameOptions.cs Adds the new options type for independently controlling query parameter names.
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs Switches QuickGrid’s query parameter naming to use QueryParameterNameOptions and defaults to direction.
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/PublicAPI.Unshipped.txt Updates the unshipped API surface to remove the old parameter and add the new type/parameter.
src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/QuickGrid/QuickGridComponent.razor Updates sample usage to pass QueryParameterNameOptions with explicit prefixes.
src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/QuickGrid/QuickGridInteractive.razor Updates interactive sample usage to pass QueryParameterNameOptions.
src/Components/test/E2ETest/Tests/QuickGridNoInteractivityTest.cs Updates URL assertions and navigation to use direction=.
src/Components/test/E2ETest/Tests/QuickGridInteractiveTest.cs Updates URL assertions and comments to use direction= and the new parameter name.
src/Components/test/E2ETest/Tests/QuickGridInteractiveCompatTest.cs Updates URL assertions to use direction= while preserving compat-mode intent.

@dariatiurina dariatiurina added this to the 11.0-preview7 milestone Jul 14, 2026

@ilonatommy ilonatommy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, 2 small ideas to consider.

@dariatiurina dariatiurina enabled auto-merge (squash) July 14, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Proposal: QuickGrid static SSR support

3 participants