diff --git a/maui/src/Expander/SfExpander.cs b/maui/src/Expander/SfExpander.cs index 6286a58..a542b6b 100644 --- a/maui/src/Expander/SfExpander.cs +++ b/maui/src/Expander/SfExpander.cs @@ -1139,7 +1139,7 @@ void OnExpanderLoaded(object? sender, EventArgs e) /// void UpdateContentViewLayoutAndVisibility() { - if ((!IsViewLoaded && !IsExpanded && FlowDirection != FlowDirection.RightToLeft && !Content!.IsVisible) || (Content == null && FlowDirection != FlowDirection.RightToLeft) || ContentView == null) + if (!IsViewLoaded || Content == null || ContentView == null) { return; } @@ -1225,7 +1225,7 @@ static Easing GetEasing(ExpanderAnimationEasing easing) /// void OnContentChanged(View? oldvalue, View? newvalue) { - if ((!IsViewLoaded && !IsExpanded && FlowDirection != FlowDirection.RightToLeft && !Content!.IsVisible) || ContentView == null) + if (!IsViewLoaded || ContentView == null) { return; } diff --git a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs index fc836d5..3459f83 100644 --- a/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs +++ b/maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs @@ -1924,6 +1924,112 @@ public void OnPropertyChanged_ShouldUpdateProperty_WhenIsEnabledChanges() Assert.False(expander.IsEnabled); } + [Fact] + public void Constructor_AllowsNullContent_AndRetainsHeader() + { + var header = new Label { Text = "Header" }; + var content = new Label { Text = "Content" }; + var expander = new SfExpander() + { + Header = header, + Content = content, + IsExpanded = true, + IsViewLoaded = true, + }; + + var oldValue = expander.Content; + expander.Content = null; + var newValue = expander.Content; + Assert.Null(expander.Content); + Assert.NotNull(expander.Header); + } + + [Fact] + public void SettingHeaderToNull_DoesNotAffectContent() + { + var content = new Label { Text = "Content" }; + var expander = new SfExpander() + { + Header = null!, + Content = content, + IsExpanded = true, + IsViewLoaded = true + }; + + Assert.Null(expander.Header); + Assert.NotNull(expander.Content); + } + + [Fact] + public void SettingHeaderAndContentToNull_DoesNotThrow() + { + var expander = new SfExpander() + { + Header = null!, + Content = null, + IsExpanded = true, + IsViewLoaded = true + }; + + Assert.Null(expander.Header); + Assert.Null(expander.Content); + } + + [Fact] + public void SettingContentToNull_RetainsHeader_WithRTL() + { + var header = new Label { Text = "Header" }; + var content = new Label { Text = "Content" }; + var expander = new SfExpander() + { + Header = header, + Content = content, + IsExpanded = true, + IsViewLoaded = true, + FlowDirection = FlowDirection.RightToLeft + }; + + expander.Content = null; + Assert.Null(expander.Content); + Assert.NotNull(expander.Header); + Assert.Equal(FlowDirection.RightToLeft, expander.FlowDirection); + } + + [Fact] + public void SettingHeaderAndContentToNull_WithRTL() + { + var expander = new SfExpander() + { + Header = null!, + Content = null, + IsExpanded = true, + IsViewLoaded = true, + FlowDirection = FlowDirection.RightToLeft + }; + + Assert.Null(expander.Header); + Assert.Null(expander.Content); + Assert.Equal(FlowDirection.RightToLeft, expander.FlowDirection); + } + + [Fact] + public void SettingHeaderToNull_RetainsContent_WithRTL() + { + var content = new Label { Text = "Content" }; + var expander = new SfExpander() + { + Header = null!, + Content = content, + IsExpanded = true, + IsViewLoaded = true, + FlowDirection = FlowDirection.RightToLeft + }; + + Assert.Null(expander.Header); + Assert.NotNull(expander.Content); + Assert.Equal(FlowDirection.RightToLeft, expander.FlowDirection); + } + #endregion }