Skip to content

Commit

Permalink
Fix Shell.NavBarIsVisible property (#20173)
Browse files Browse the repository at this point in the history
* Fix the issue

* Added XAML Test
  • Loading branch information
jsuarezruiz authored Aug 13, 2024
1 parent 6fa52c6 commit 210bc35
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ internal static void PropagatePropertyChanged(string propertyName, Element eleme

if (propertyName == null || propertyName == Shell.TabBarIsVisibleProperty.PropertyName)
BaseShellItem.PropagateFromParent(Shell.TabBarIsVisibleProperty, element);

if (propertyName == null || propertyName == Shell.NavBarIsVisibleProperty.PropertyName)
BaseShellItem.PropagateFromParent(Shell.NavBarIsVisibleProperty, element);

foreach (var child in children)
{
Expand Down
16 changes: 16 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Issue18948.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Shell
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Issue18948"
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests"
Shell.NavBarIsVisible="False">
<ShellContent
Title="One"
ContentTemplate="{DataTemplate local:Maui11204}"
Route="One" />
<ShellContent
Title="Two"
ContentTemplate="{DataTemplate local:Maui11204}"
Route="Two" />
</Shell>
30 changes: 30 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Issue18948.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using NUnit.Framework;

namespace Microsoft.Maui.Controls.Xaml.UnitTests
{
public partial class Issue18948 : Shell
{
public Issue18948()
{
InitializeComponent();
}
public Issue18948(bool useCompiledXaml)
{
// This stub will be replaced at compile time
}

[TestFixture]
public class Tests
{
[TestCase(false)]
[TestCase(true)]
public void NavBarIsVisiblePropertyPropagates(bool useCompiledXaml)
{
var shell = new Issue18948(useCompiledXaml);
var navBarIsVisible = Shell.GetNavBarIsVisible(shell.CurrentContent);
Assert.False(navBarIsVisible);
}
}
}
}

0 comments on commit 210bc35

Please sign in to comment.