Skip to content

Simplify QuickGrid OnRowClick rendering by removing conditional duplication#64621

Merged
javiercn merged 2 commits intojaviercn/quickgrid-row-click-eventfrom
copilot/sub-pr-64602
Dec 3, 2025
Merged

Simplify QuickGrid OnRowClick rendering by removing conditional duplication#64621
javiercn merged 2 commits intojaviercn/quickgrid-row-click-eventfrom
copilot/sub-pr-64602

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

Simplify QuickGrid OnRowClick rendering by removing conditional duplication

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Address review feedback on QuickGrid OnRowClick implementation

Description

Addresses feedback from #64602 to simplify the RenderRow method by removing duplicated <tr> element rendering.

Changes:

  • Coalesce OnRowClick callback into a local variable using EventCallback.Factory.Create
  • Remove if/else block that duplicated the entire <tr> element
  • Always pass @onclick to the row—RenderTreeBuilder.AddAttribute already elides the attribute when the callback has no delegate
var rowClick = OnRowClick.HasDelegate 
    ? EventCallback.Factory.Create<MouseEventArgs>(this, () => OnRowClick.InvokeAsync(item)) 
    : default;

<tr @key="@(ItemKey(item))" aria-rowindex="@rowIndex" class="@combinedClass" @onclick="@rowClick">

Fixes #64602


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@dotnet-policy-service
Copy link
Contributor

Greetings! You've submitted a PR that modifies code that is shared with https://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo!

…back

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix feedback on adding OnRowClick EventCallback to QuickGrid Simplify QuickGrid OnRowClick rendering by removing conditional duplication Dec 3, 2025
Copilot AI requested a review from javiercn December 3, 2025 08:51
@javiercn javiercn marked this pull request as ready for review December 3, 2025 11:15
@javiercn javiercn requested a review from a team as a code owner December 3, 2025 11:15
@javiercn javiercn merged commit e3cd250 into javiercn/quickgrid-row-click-event Dec 3, 2025
25 checks passed
@javiercn javiercn deleted the copilot/sub-pr-64602 branch December 3, 2025 11:21
javiercn added a commit that referenced this pull request Dec 3, 2025
…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>
javiercn added a commit that referenced this pull request Dec 4, 2025
* Add OnRowClick EventCallback to QuickGrid

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

* Add OnRowClick EventCallback to QuickGrid (#64606)

* 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>

* Simplify QuickGrid OnRowClick rendering by removing conditional duplication (#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>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants