894511 : Shell Tab is still visible after set Tab.IsVisible to false (#24161)
* 894511 : Shell Tab is still visible after set Tab.IsVisible to false * Commit for test cases changes * 894511 : Review changes * Commit for testcase changes * Commit for proper flyout width * Review changes * Image added * 894511 : Commit for windows * 894511 : Fix for iOS included * Fix: 894511 : Review changes * Fix:894511 : Images Added
This commit is contained in:
Родитель
c6600c6a35
Коммит
1dfe609c27
|
@ -295,7 +295,13 @@ namespace Microsoft.Maui.Controls.Platform.Compatibility
|
|||
oldPage.PropertyChanged -= OnDisplayedElementPropertyChanged;
|
||||
|
||||
if (newPage is not null)
|
||||
{
|
||||
newPage.PropertyChanged += OnDisplayedElementPropertyChanged;
|
||||
if (oldPage is null)
|
||||
{
|
||||
_menuSetup = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (newPage is not null && !_menuSetup)
|
||||
{
|
||||
|
|
|
@ -357,6 +357,10 @@ namespace Microsoft.Maui.Controls.Platform.Compatibility
|
|||
if (shellSection == null || _currentSection == shellSection)
|
||||
return;
|
||||
var renderer = RendererForShellContent(shellSection);
|
||||
|
||||
if (renderer == null)
|
||||
return;
|
||||
|
||||
if (renderer?.ViewController != SelectedViewController)
|
||||
SelectedViewController = renderer.ViewController;
|
||||
CurrentRenderer = renderer;
|
||||
|
|
|
@ -432,7 +432,7 @@ namespace Microsoft.Maui.Controls.Handlers
|
|||
if (_mainLevelTabs == null)
|
||||
return;
|
||||
|
||||
var currentItem = VirtualView.CurrentItem.CurrentItem;
|
||||
var currentItem = VirtualView.CurrentItem?.CurrentItem;
|
||||
NavigationViewItemViewModel? navigationViewItemViewModel = null;
|
||||
|
||||
foreach (var item in _mainLevelTabs)
|
||||
|
|
|
@ -284,7 +284,10 @@ namespace Microsoft.Maui.Controls
|
|||
var shellItem = (ShellItem)bindable;
|
||||
|
||||
if (newValue == null)
|
||||
{
|
||||
shellItem.CurrentItem = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (shellItem.Parent is Shell)
|
||||
{
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 32 KiB |
|
@ -0,0 +1,25 @@
|
|||
<?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="Maui.Controls.Sample.Issues.Issue8788"
|
||||
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
|
||||
Shell.FlyoutBehavior="Locked"
|
||||
Shell.FlyoutWidth="200">
|
||||
|
||||
<MenuItem x:Name="MenuItem" Text="Click to hide Tab1" Clicked="MenuItem_Clicked" AutomationId="FirstButton" />
|
||||
|
||||
<TabBar>
|
||||
<Tab x:Name="Tab1" AutomationId="Tab1" Title="Tab 1">
|
||||
<ShellContent Title="Tab 1" ContentTemplate="{DataTemplate local:MainTabPage}" Route="MainPage" />
|
||||
</Tab>
|
||||
|
||||
<Tab x:Name="Tab2" AutomationId="Tab2" Title="Tab 2" IsVisible="false">
|
||||
<ShellContent Title="Tab 2" ContentTemplate="{DataTemplate local:SecondTabPage}" Route="Tab2Page" />
|
||||
</Tab>
|
||||
|
||||
<Tab x:Name="Tab3" Title="Tab 3" AutomationId="Tab3" IsVisible="false">
|
||||
<ShellContent Title="Tab 3" ContentTemplate="{DataTemplate local:ThirdTabPage}" Route="Tab3Page" />
|
||||
</Tab>
|
||||
</TabBar>
|
||||
|
||||
</Shell>
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Maui.Controls.Sample.Issues
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
[Issue(IssueTracker.Github, 8788, "Shell Tab is still visible after set Tab.IsVisible to false", PlatformAffected.Android)]
|
||||
public partial class Issue8788 : Shell
|
||||
{
|
||||
public Issue8788()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void MenuItem_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
#if ANDROID
|
||||
Tab2.IsVisible = true;
|
||||
Tab3.IsVisible = true;
|
||||
Tab1.IsVisible = false;
|
||||
#else
|
||||
Tab1.IsVisible = false;
|
||||
Tab2.IsVisible = true;
|
||||
Tab3.IsVisible = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public partial class MainTabPage : ContentPage
|
||||
{
|
||||
public MainTabPage()
|
||||
{
|
||||
Content = new VerticalStackLayout()
|
||||
{
|
||||
new Label(){
|
||||
Text = "Page Loaded in first Tab",
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
TextDecorations = TextDecorations.Underline,
|
||||
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SecondTabPage : ContentPage
|
||||
{
|
||||
public SecondTabPage()
|
||||
{
|
||||
Content = new VerticalStackLayout()
|
||||
{
|
||||
new Label(){
|
||||
Text = "Page Loaded in Second Tab",
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
TextDecorations = TextDecorations.Underline,
|
||||
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
public partial class ThirdTabPage : ContentPage
|
||||
{
|
||||
public ThirdTabPage()
|
||||
{
|
||||
Content = new VerticalStackLayout()
|
||||
{
|
||||
new Label(){
|
||||
Text = "Page Loaded in Third Tab",
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
TextDecorations = TextDecorations.Underline,
|
||||
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#if !MACCATALYST
|
||||
using NUnit.Framework;
|
||||
using UITest.Appium;
|
||||
using UITest.Core;
|
||||
|
||||
namespace Microsoft.Maui.TestCases.Tests.Issues
|
||||
{
|
||||
internal class Issue8788 : _IssuesUITest
|
||||
{
|
||||
public Issue8788(TestDevice device) : base(device) { }
|
||||
|
||||
public override string Issue => "Shell Tab is still visible after set Tab.IsVisible to false";
|
||||
|
||||
[Test]
|
||||
[Category(UITestCategories.Shell)]
|
||||
public void ShellTabItemsShouldUpdateForDynamicChangesInVisibility()
|
||||
{
|
||||
#if WINDOWS
|
||||
App.TapCoordinates(100, 57);
|
||||
#else
|
||||
App.WaitForElement("FirstButton");
|
||||
App.Tap("FirstButton");
|
||||
#endif
|
||||
VerifyScreenshot();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 9.2 KiB |
Двоичные данные
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ShellTabItemsShouldUpdateForDynamicChangesInVisibility.png
Normal file
Двоичные данные
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ShellTabItemsShouldUpdateForDynamicChangesInVisibility.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 72 KiB |
Загрузка…
Ссылка в новой задаче