-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Blazor] Add OnRowClick EventCallback to QuickGrid #64602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds an OnRowClick EventCallback parameter to the QuickGrid component, enabling developers to handle row click events. The implementation conditionally applies the row-clickable CSS class and click handler when the callback is set, with accompanying E2E tests to verify functionality.
Key Changes:
- Added
OnRowClickEventCallback parameter to QuickGrid - Implemented conditional rendering in
RenderRowto attach click handlers and apply styling when the callback is set - Added CSS styling (
cursor: pointer) for clickable rows via therow-clickableclass
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| QuickGrid.razor | Modified RenderRow method to conditionally apply click handlers and row-clickable class based on OnRowClick.HasDelegate |
| QuickGrid.razor.cs | Added OnRowClick parameter with XML documentation |
| QuickGrid.razor.css | Added .row-clickable CSS class with cursor: pointer styling |
| PublicAPI.Unshipped.txt | Documented the new public API getter/setter for OnRowClick |
| SampleQuickGridComponent.razor | Updated test component to include row click handling with state tracking |
| QuickGridTest.cs | Added E2E tests verifying callback invocation and cursor styling |
| Agents.md | New documentation file (unrelated to this PR's purpose) |
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor
Outdated
Show resolved
Hide resolved
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.cs
Show resolved
Hide resolved
src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor
Show resolved
Hide resolved
src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor
Show resolved
Hide resolved
|
@copilot fix the following test Update to match the expectations as needed. Also implement the suggestion from
You can remove the commit about Agents.md from this change too. Anything else, leave it be. |
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor
Outdated
Show resolved
Hide resolved
This change adds an OnRowClick parameter to QuickGrid that allows users to handle row click events. When the OnRowClick delegate is set: - The row receives a 'row-clickable' CSS class - A cursor: pointer style is applied via scoped CSS - Clicking the row invokes the callback with the row item Fixes #44899
* Initial plan * Fix RowClassApplied test and consolidate RenderRow logic Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com> * Fix trailing space in combinedClass when rowClass is null Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
…cation (#64621) * Initial plan * Simplify RenderRow by removing if/else and coalescing OnRowClick callback Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
e3cd250 to
d16f068
Compare
| : rowClass; | ||
| var rowClick = OnRowClick.HasDelegate ? EventCallback.Factory.Create<MouseEventArgs>(this, () => OnRowClick.InvokeAsync(item)) : default; | ||
|
|
||
| <tr @key="@(ItemKey(item))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the row click behave when it comes to propagation? Will a click on the element bubble up to its ancestor DOM element? Do we have to support stopPropagation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blazor uses event delegation for handling events. All events bubble up to the root where the handler intercepts them and then dispatches to the appropriate Blazor code. We normally don't stop event propagation unless we have good reasons to.
Summary
This PR adds a new
OnRowClickparameter to theQuickGridcomponent, allowing users to handle row click events. This addresses a common scenario where developers need to respond to user clicks on grid rows.Fixes #44899
Changes
OnRowClickparameter of typeEventCallback<TGridItem>toQuickGridrow-clickableCSS classcursor: pointerstyle is applied via scoped CSSUsage Example
Files Changed
QuickGrid.razorQuickGrid.razor.csOnRowClickparameter with XML docsQuickGrid.razor.css.row-clickableCSS class with cursor:pointerPublicAPI.Unshipped.txtSampleQuickGridComponent.razorQuickGridTest.cs