[dev-v5][Datagrid] Add OnSortChanged event callback#4572
Open
[dev-v5][Datagrid] Add OnSortChanged event callback#4572
Conversation
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.9%
|
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds a new OnSortChanged event callback to the FluentDataGrid component, enabling consumers to react to sort order changes. The implementation includes a new event argument class, updates to sorting methods to trigger the callback, and comprehensive unit tests to verify the functionality.
Changes:
- Added
DataGridSortEventArgs<TGridItem>class to provide sort event information (column and direction) - Added
OnSortChangedevent callback parameter toFluentDataGridcomponent - Modified
SortByColumnAsyncandRemoveSortByColumnAsyncmethods to invoke the callback when sorting changes - Added comprehensive unit test
FluentDataGrid_OnSortChanged_Firescovering sorting, toggling, and removal scenarios - Updated version suffix from
alpha.1toRC.2
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Core/Events/DataGridSortEventArgs.cs | New event argument class providing column and sort direction information |
| src/Core/Components/DataGrid/FluentDataGrid.razor.cs | Added OnSortChanged parameter and updated sorting methods to invoke callback |
| tests/Core/Components/DataGrid/FluentDataGridTests.razor | Added comprehensive test verifying the event fires correctly in all scenarios |
| Directory.Build.props | Updated version suffix to RC.2 for new release candidate |
Comments suppressed due to low confidence (2)
src/Core/Events/DataGridSortEventArgs.cs:11
- The DataGridSortEventArgs class should inherit from EventArgs to follow the established pattern in this codebase. All public event argument classes inherit from EventArgs (see AccordionItemEventArgs and MenuItemEventArgs), while only internal event argument classes may skip this inheritance. Since DataGridSortEventArgs is public, it should inherit from EventArgs for consistency.
public class DataGridSortEventArgs<TGridItem>
src/Core/Components/DataGrid/FluentDataGrid.razor.cs:696
- The statement 'await Task.CompletedTask' is unnecessary and serves no purpose. Task.CompletedTask is already a completed task, so awaiting it adds no value. The method can simply return at this point without any await statement.
await Task.CompletedTask;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 introduces a new event callback for sort changes in the
FluentDataGridcomponent, allowing consumers to respond when the grid's sort order changes. The implementation includes a new event argument class, updates to sorting methods to invoke the callback, and corresponding unit tests to verify the new functionality.New sort event feature
[Parameter]propertyOnSortChangedtoFluentDataGrid, enabling consumers to handle sort order changes via an event callback.DataGridSortEventArgs<TGridItem>class to provide detailed information about the sort event, including the sorted column and direction.Updates to sorting methods
SortByColumnAsyncandRemoveSortByColumnAsyncmethods to beasyncand to invoke theOnSortChangedcallback with the appropriate event arguments when the sort order changes. [1] [2] [3]Testing
FluentDataGrid_OnSortChanged_Firesto verify that theOnSortChangedevent fires correctly and provides the expected event arguments when the sort order is changed or removed.Version update
Directory.Build.propsfromalpha.1toRC.2to reflect the new release candidate.