Skip to content
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

ParameterState: Fix when subscribing only to EventCallback #8457

Merged
merged 1 commit into from
Mar 25, 2024

Conversation

ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Mar 25, 2024

Description

This fixes an interesting problem when you subscribe only to EventCallback and modify the child, for example you have content collapsed and you want to expand it via public method like ToggleAsync, the content would not expand, when it should.

This problem was found here: #8446

Consider this as example:

<MudExpansionPanels>
	<MudExpansionPanel Text="Panel with async loaded contents" MaxHeight="1000" IsExpandedChanged="ExpandedChanged">
		Secret content
	</MudExpansionPanel>
</MudExpansionPanels>

@code {
    private void ExpandedChanged(bool newVal)
    {   
    }
}

Note that when you click on expansion, you are triggering inner child toggle method

Before

before

After

after

The line in unit tests that specifically tests that this moment is covered:

alertChild3TextFunc().InnerHtml.Should().Be("Oh my! We got secret content3!");

and
comp.Instance.Child3Instance.IsExpandedStateValue.Should().BeTrue();

aka the content must show when clicked and state should correspond that it's opened, before the fix this would fail.

How Has This Been Tested?

New bUnit tests that took me few hours to make...

Types 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)

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 Something does not work as intended/expected PR: needs review labels Mar 25, 2024
@ScarletKuro
Copy link
Member Author

@henon I'm merging this ASAP, but just FYI and I recommend you to rebase your branches where you work on ParameterState.

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.83%. Comparing base (9bb4af1) to head (16d2339).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #8457      +/-   ##
==========================================
+ Coverage   88.76%   88.83%   +0.06%     
==========================================
  Files         416      416              
  Lines       12359    12358       -1     
  Branches     2458     2458              
==========================================
+ Hits        10971    10978       +7     
+ Misses        855      846       -9     
- Partials      533      534       +1     

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

@ScarletKuro ScarletKuro merged commit 61e8a76 into MudBlazor:dev Mar 25, 2024
4 checks passed
@ScarletKuro ScarletKuro deleted the state_fix branch March 25, 2024 02:49
peterthorpe81 pushed a commit to peterthorpe81/MudBlazor that referenced this pull request Mar 25, 2024
henon pushed a commit that referenced this pull request Mar 25, 2024
biegehydra pushed a commit to biegehydra/MudBlazor that referenced this pull request Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant