Skip to content

MudNavGroup: Fix NavigationContext not updating on Expanded#9101

Merged
ScarletKuro merged 2 commits intoMudBlazor:devfrom
ScarletKuro:colorpicker_1
Jun 3, 2024
Merged

MudNavGroup: Fix NavigationContext not updating on Expanded#9101
ScarletKuro merged 2 commits intoMudBlazor:devfrom
ScarletKuro:colorpicker_1

Conversation

@ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Jun 2, 2024

Description

Fixes issue mentioned here: #8976 (comment)
Regression PR: #8684

How Has This Been Tested?

Visually, added bUnit test.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

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

@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Jun 2, 2024
@ScarletKuro ScarletKuro requested a review from henon June 2, 2024 19:43
@ScarletKuro
Copy link
Member Author

Adding @igotinfected for review too.

Also let me know if we need test for this case.

@codecov
Copy link

codecov bot commented Jun 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.65%. Comparing base (28bc599) to head (00ec021).
Report is 1103 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9101      +/-   ##
==========================================
+ Coverage   89.82%   90.65%   +0.82%     
==========================================
  Files         412      398      -14     
  Lines       11878    12381     +503     
  Branches     2364     2406      +42     
==========================================
+ Hits        10670    11224     +554     
+ Misses        681      620      -61     
- Partials      527      537      +10     

☔ 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.

@igotinfected
Copy link
Member

Adding @igotinfected for review too.

Also let me know if we need test for this case.

Thanks for the fix, and sorry for the regression!

I suggest adding this as a test:

/// <summary>
/// NavGroup should expand and collapse via Expanded binding.
/// </summary>
[Test]
public async Task NavGroup_should_expand_via_Expanded_binding()
{
    var comp = Context.RenderComponent<NavGroupWithExpandedBindingTest>();
    GetExpandedState().Should().BeFalse();

    await comp.InvokeAsync(() => comp.Find("#navgroup-switch").Change(true));

    GetExpandedState().Should().BeTrue();

    await comp.InvokeAsync(() => comp.Find("#navgroup-switch").Change(false));

    GetExpandedState().Should().BeFalse();
    return;

    bool GetExpandedState() => comp.FindComponent<MudCollapse>().Instance.Expanded;
}

With this as test component (covering the user's test case):

<MudNavGroup Icon="@Icons.Material.Filled.ManageAccounts"
             Title="Users"
             Expanded="@_expanded">
    <MudNavLink Href="profile"
                Match="NavLinkMatch.Prefix"
                Icon="@Icons.Material.Filled.Person">
        Profile
    </MudNavLink>
</MudNavGroup>

<MudSwitch T="bool"
           id="navgroup-switch"
           @bind-Value="@_expanded"
           Label="Expand navigation group" />

@code {
    private bool _expanded;
}

@ScarletKuro
Copy link
Member Author

Thx for the test.

Copy link
Contributor

@henon henon left a comment

Choose a reason for hiding this comment

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

👍

@ScarletKuro ScarletKuro merged commit 7c6d28b into MudBlazor:dev Jun 3, 2024
@ScarletKuro ScarletKuro deleted the colorpicker_1 branch June 3, 2024 09:44
@danielchalmers danielchalmers added regression Previously worked and now doesn't and removed accidental break labels Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended regression Previously worked and now doesn't

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants