Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

GeorgeKarlinzer
Copy link
Contributor

Add HierarchyVisibilityToggled parameter on MudDataGrid component, that allows user to perform custom actions when row is expanded/collapsed. The parameter is triggered when grid row is expanded or collapsed.

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the style of this project.
  • I've added relevant tests or tested on existing ones.

@versile2
Copy link
Contributor

Check to see if this duplicates any of #11292

@GeorgeKarlinzer
Copy link
Contributor Author

@versile2 no same code with #11292

@versile2
Copy link
Contributor

So should we close this one if we merge that one? Or does that one have anything this one doesn't? You did the work would be nice to get some credit.

@github-actions github-actions bot added the enhancement Request for adding a new feature or enhancing existing functionality (not fixing a defect) label Jul 30, 2025
@GeorgeKarlinzer
Copy link
Contributor Author

I think these are two unrelated issues, so you can merge both.

@danielchalmers
Copy link
Member

danielchalmers commented Jul 30, 2025

Merged #11292 - new conflicts on this PR

I'll try to get both merged before the next release

@danielchalmers danielchalmers requested a review from versile2 July 30, 2025 19:27
@versile2
Copy link
Contributor

versile2 commented Aug 1, 2025

@GeorgeKarlinzer If you'll bring this branch up to date, ensure the tests still pass and that it solves your problem then tag me I'll review and we'll get it merged as soon as we can.

@github-actions github-actions bot changed the title DataGrid: Add hierarchy visibility toggled parameter MudDataGrid: Add hierarchy visibility toggled parameter Aug 3, 2025
@GeorgeKarlinzer GeorgeKarlinzer force-pushed the feature/data-grid-hierarchy-toggled-parameter branch from 88fca2f to 4e126db Compare August 4, 2025 06:06
@GeorgeKarlinzer GeorgeKarlinzer changed the title MudDataGrid: Add hierarchy visibility toggled parameter WIP MudDataGrid: Add hierarchy visibility toggled parameter Aug 4, 2025
@GeorgeKarlinzer
Copy link
Contributor Author

@versile2 all done :)

@GeorgeKarlinzer GeorgeKarlinzer changed the title WIP MudDataGrid: Add hierarchy visibility toggled parameter MudDataGrid: Add hierarchy visibility toggled parameter Aug 4, 2025
@versile2 versile2 requested a review from Copilot August 4, 2025 16:00
Copy link
Contributor

@Copilot Copilot AI left a 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 a HierarchyVisibilityToggled parameter to the MudDataGrid component that allows users to perform custom actions when grid rows are expanded or collapsed.

  • Added HierarchyVisibilityToggled EventCallback parameter to trigger custom actions on hierarchy visibility changes
  • Created DataGridHierarchyVisibilityToggledEventArgs class to provide event information
  • Updated hierarchy methods to invoke the new event callback when items are expanded/collapsed

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
MudDataGrid.razor.cs Added HierarchyVisibilityToggled parameter and event invocations in hierarchy management methods
DataGridHierarchyVisibilityToggledEventArgs.cs New event args class containing item and expanded state information
DataGridTests.cs Added unit tests for the new hierarchy visibility toggled functionality
DataGridHierarchyVisibilityToggledTest.razor Test component demonstrating the new event callback usage

/// <summary>
/// The item whose visibility was changed.
/// </summary>
public T Item { get; set; }
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The Item property should have an initializer or be marked as required to prevent null reference issues, as this is event args data that should always contain a valid item.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

not sure here, most other event args don't have a setter and instead set during constructor which is basically the same thing as required.

/// </summary>
public T Item { get; set; }
/// <summary>
/// If <code>true</code> item was expanded, otherwise collapsed
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The documentation comment uses inconsistent formatting. It should use backticks instead of tags for inline code: 'If true item was expanded, otherwise collapsed'.

Suggested change
/// If <code>true</code> item was expanded, otherwise collapsed
/// If `true` item was expanded, otherwise collapsed

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@versile2 versile2 Aug 4, 2025

Choose a reason for hiding this comment

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

the backticks isn't right, however <c> does what you want here, <code> just makes it separate a line. Remember you can always mouse over the property to see what it will look like in Intellisense.

Comment on lines 2380 to 2381
if (!_buttonDisabledFunc(item) && _openHierarchies.Add(item))
{
Copy link
Preview

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

The Add operation is performed even when the item is already in the set. Consider checking if the item exists first to avoid unnecessary event invocations: if (!_buttonDisabledFunc(item) && !_openHierarchies.Contains(item)).

Suggested change
if (!_buttonDisabledFunc(item) && _openHierarchies.Add(item))
{
if (!_buttonDisabledFunc(item) && !_openHierarchies.Contains(item))
{
_openHierarchies.Add(item);

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that this is not the case, the HashSet<T>.Add method description explicitly says that false is returned when an item is already in the set. Demo: https://dotnetfiddle.net/bZE8nb

Copy link
Contributor

Choose a reason for hiding this comment

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

Look at sonarcube report. I don't have access to a computer right now but can that part be simplified based on a LINQ where?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@danielchalmers
Copy link
Member

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new HierarchyVisibilityToggled parameter to the MudDataGrid component, enabling users to perform custom actions when a row's hierarchy is expanded or collapsed. The changes include modifications to the MudDataGrid component and the addition of a new event argument class, along with corresponding unit tests.

Copy link

codecov bot commented Aug 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (dev@890d4b6). Learn more about missing BASE report.
⚠️ Report is 3 commits behind head on dev.

Additional details and impacted files
@@          Coverage Diff           @@
##             dev   #11706   +/-   ##
======================================
  Coverage       ?   91.31%           
======================================
  Files          ?      467           
  Lines          ?    14728           
  Branches       ?     2870           
======================================
  Hits           ?    13449           
  Misses         ?      636           
  Partials       ?      643           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

sonarqubecloud bot commented Aug 6, 2025

Copy link
Contributor

@versile2 versile2 left a comment

Choose a reason for hiding this comment

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

Good work.

@versile2 versile2 requested a review from danielchalmers August 6, 2025 11:00
@danielchalmers
Copy link
Member

Thanks!

This was referenced Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request for adding a new feature or enhancing existing functionality (not fixing a defect)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants