Skip to content

Commit 7d98638

Browse files
Merge pull request #257 from syncfusion/automation_issue
981096 - Expander Header not Visible When Content is Null on Windows Platform.
2 parents 8802715 + 83e8241 commit 7d98638

File tree

2 files changed

+108
-2
lines changed

2 files changed

+108
-2
lines changed

maui/src/Expander/SfExpander.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ void OnExpanderLoaded(object? sender, EventArgs e)
11391139
/// </summary>
11401140
void UpdateContentViewLayoutAndVisibility()
11411141
{
1142-
if ((!IsViewLoaded && !IsExpanded && FlowDirection != FlowDirection.RightToLeft && !Content!.IsVisible) || (Content == null && FlowDirection != FlowDirection.RightToLeft) || ContentView == null)
1142+
if (!IsViewLoaded || Content == null || ContentView == null)
11431143
{
11441144
return;
11451145
}
@@ -1225,7 +1225,7 @@ static Easing GetEasing(ExpanderAnimationEasing easing)
12251225
/// <param name="newvalue"></param>
12261226
void OnContentChanged(View? oldvalue, View? newvalue)
12271227
{
1228-
if ((!IsViewLoaded && !IsExpanded && FlowDirection != FlowDirection.RightToLeft && !Content!.IsVisible) || ContentView == null)
1228+
if (!IsViewLoaded || ContentView == null)
12291229
{
12301230
return;
12311231
}

maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Layout/SfExpanderUnitTests.cs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,112 @@ public void OnPropertyChanged_ShouldUpdateProperty_WhenIsEnabledChanges()
19241924
Assert.False(expander.IsEnabled);
19251925
}
19261926

1927+
[Fact]
1928+
public void Constructor_AllowsNullContent_AndRetainsHeader()
1929+
{
1930+
var header = new Label { Text = "Header" };
1931+
var content = new Label { Text = "Content" };
1932+
var expander = new SfExpander()
1933+
{
1934+
Header = header,
1935+
Content = content,
1936+
IsExpanded = true,
1937+
IsViewLoaded = true,
1938+
};
1939+
1940+
var oldValue = expander.Content;
1941+
expander.Content = null;
1942+
var newValue = expander.Content;
1943+
Assert.Null(expander.Content);
1944+
Assert.NotNull(expander.Header);
1945+
}
1946+
1947+
[Fact]
1948+
public void SettingHeaderToNull_DoesNotAffectContent()
1949+
{
1950+
var content = new Label { Text = "Content" };
1951+
var expander = new SfExpander()
1952+
{
1953+
Header = null!,
1954+
Content = content,
1955+
IsExpanded = true,
1956+
IsViewLoaded = true
1957+
};
1958+
1959+
Assert.Null(expander.Header);
1960+
Assert.NotNull(expander.Content);
1961+
}
1962+
1963+
[Fact]
1964+
public void SettingHeaderAndContentToNull_DoesNotThrow()
1965+
{
1966+
var expander = new SfExpander()
1967+
{
1968+
Header = null!,
1969+
Content = null,
1970+
IsExpanded = true,
1971+
IsViewLoaded = true
1972+
};
1973+
1974+
Assert.Null(expander.Header);
1975+
Assert.Null(expander.Content);
1976+
}
1977+
1978+
[Fact]
1979+
public void SettingContentToNull_RetainsHeader_WithRTL()
1980+
{
1981+
var header = new Label { Text = "Header" };
1982+
var content = new Label { Text = "Content" };
1983+
var expander = new SfExpander()
1984+
{
1985+
Header = header,
1986+
Content = content,
1987+
IsExpanded = true,
1988+
IsViewLoaded = true,
1989+
FlowDirection = FlowDirection.RightToLeft
1990+
};
1991+
1992+
expander.Content = null;
1993+
Assert.Null(expander.Content);
1994+
Assert.NotNull(expander.Header);
1995+
Assert.Equal(FlowDirection.RightToLeft, expander.FlowDirection);
1996+
}
1997+
1998+
[Fact]
1999+
public void SettingHeaderAndContentToNull_WithRTL()
2000+
{
2001+
var expander = new SfExpander()
2002+
{
2003+
Header = null!,
2004+
Content = null,
2005+
IsExpanded = true,
2006+
IsViewLoaded = true,
2007+
FlowDirection = FlowDirection.RightToLeft
2008+
};
2009+
2010+
Assert.Null(expander.Header);
2011+
Assert.Null(expander.Content);
2012+
Assert.Equal(FlowDirection.RightToLeft, expander.FlowDirection);
2013+
}
2014+
2015+
[Fact]
2016+
public void SettingHeaderToNull_RetainsContent_WithRTL()
2017+
{
2018+
var content = new Label { Text = "Content" };
2019+
var expander = new SfExpander()
2020+
{
2021+
Header = null!,
2022+
Content = content,
2023+
IsExpanded = true,
2024+
IsViewLoaded = true,
2025+
FlowDirection = FlowDirection.RightToLeft
2026+
};
2027+
2028+
Assert.Null(expander.Header);
2029+
Assert.NotNull(expander.Content);
2030+
Assert.Equal(FlowDirection.RightToLeft, expander.FlowDirection);
2031+
}
2032+
19272033
#endregion
19282034

19292035
}

0 commit comments

Comments
 (0)