Skip to content

Conversation

RasikaPalanisamy
Copy link
Collaborator

@RasikaPalanisamy RasikaPalanisamy commented Sep 12, 2025

Description
When setting the Expander content to null in the constructor, the Expander header also becomes invisible in Windows Platform.

Root Cause
Setting the Expander content to null in the constructor causes its height to become zero. The expander header height is not calculated correctly.

Solution Description
In the OnContentChanged method, when content is set to null, the method should return early. However, it continues execution and calls UpdateContentViewLayoutAndVisibility, which also should return but instead calls ApplyAnimation. In the ApplyAnimation method, IsAnimationInProgress becomes true. The height is calculated only when IsAnimationInProgress becomes false. So, changed return conditions in OnContentChanged and UpdateContentViewLayoutAndVisibility to prevent unnecessary execution and ensure proper height calculation.

Task ID
Task 981096

Before:

image

After:

image

Test Case
Added 6 test cases. All cases are passed.
image

MR CheckList

  • Have you ensured in iOS, Android, WinUI, and macOS(if supported)? Android, WinUI
  • If there is any API change, did you get approval from PLO through JIRA Tasks? No
  • Is there any existing behavior change of other features due to this code change? No
  • Did you perform the automation / manual testing against your fix?
  • Did you record this case in the unit test or UI test?
  • Have you suppressed any warning or binding errors? No
  • Is there any existing behavior change of other features due to this code change? No
  • Does it need localization? If so did you ensure the cases mentioned in this link? No
  • Whether the new APIs and its comments are added as per standard? No
  • Did you ensure the cases mentioned in this link? Not Applicable
  • Did you ensure the fix (if applicable) met accessibility requirements? Not Applicable
  • If you added any interaction related code, have you used touch and gesture APIs from core project? Not Applicable
  • Does it contain code that reflects any internal framework API? Not Applicable
  • Did you ensure the cases mentioned in this link? Not Applicable
  • Did you ensure RTL? Not Applicable
  • Did you test the memory leak with the fix? Not Applicable
  • Did you ensure the ? Check this link to know more about performance optimization and how to automate? Not Applicable
  • If you use a third-party package, did you get approval to use it? If not, please get approval before merging. Not Applicable

@PaulAndersonS
Copy link
Collaborator

/azp run

Copy link

@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 fixes an issue where the Expander header becomes invisible on Windows when content is set to null, caused by incorrect height calculation during animation state management.

Key changes:

  • Simplified early return conditions in OnContentChanged and UpdateContentViewLayoutAndVisibility methods
  • Added comprehensive test coverage for null content scenarios including RTL support

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
maui/src/Expander/SfExpander.cs Simplified return conditions to prevent unnecessary animation processing when content is null
maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs Added 6 test cases covering null content scenarios with and without RTL support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

void UpdateContentViewLayoutAndVisibility()
{
if ((!IsViewLoaded && !IsExpanded && FlowDirection != FlowDirection.RightToLeft && !Content!.IsVisible) || (Content == null && FlowDirection != FlowDirection.RightToLeft) || ContentView == null)
if (!IsViewLoaded || Content == null || ContentView == null)
Copy link
Preview

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

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

The simplified condition removes important checks for IsExpanded, FlowDirection, and Content.IsVisible. While this may fix the immediate issue, it could potentially affect other scenarios. Consider adding a comment explaining why these conditions were removed to help future maintainers understand the reasoning.

Suggested change
if (!IsViewLoaded || Content == null || ContentView == null)
// The following checks are necessary to ensure that the content view layout and visibility
// are only updated when the expander is loaded, expanded, in a valid flow direction,
// and the content is visible. Removing these checks may cause unexpected behavior in
// certain scenarios. See CodeQL rule: "The simplified condition removes important checks for
// IsExpanded, FlowDirection, and Content.IsVisible."
if (!IsViewLoaded || Content == null || ContentView == null || !IsExpanded || FlowDirection == FlowDirection.MatchParent || !Content.IsVisible)

Copilot uses AI. Check for mistakes.

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PaulAndersonS PaulAndersonS merged commit 7d98638 into main Sep 12, 2025
2 checks passed
@PaulAndersonS PaulAndersonS added this to the v1.0.7 milestone Sep 12, 2025
void UpdateContentViewLayoutAndVisibility()
{
if ((!IsViewLoaded && !IsExpanded && FlowDirection != FlowDirection.RightToLeft && !Content!.IsVisible) || (Content == null && FlowDirection != FlowDirection.RightToLeft) || ContentView == null)
if (!IsViewLoaded || Content == null || ContentView == null)

Choose a reason for hiding this comment

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

If the issue is only on Windows, is it wise to remove all of it for all the platforms?

Choose a reason for hiding this comment

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

got it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants