Skip to content

Commit

Permalink
Update Flyout when Shell.FlyoutContent changes (#17359)
Browse files Browse the repository at this point in the history
* Update Flyout when Shell.FlyoutContent changes

* Add test: FlyoutContentUpdatesAfterChange
  • Loading branch information
spadapet committed Sep 26, 2023
1 parent e5c2853 commit bb8a913
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Controls/src/Core/Handlers/Shell/ShellHandler.cs
Expand Up @@ -21,6 +21,7 @@ public partial class ShellHandler
[nameof(IFlyoutView.FlyoutWidth)] = MapFlyoutWidth,
[nameof(Shell.FlyoutBackground)] = MapFlyoutBackground,
[nameof(Shell.FlyoutBackgroundColor)] = MapFlyoutBackground,
[nameof(Shell.FlyoutContent)] = MapFlyout,
[nameof(Shell.CurrentItem)] = MapCurrentItem,
[nameof(Shell.FlyoutBackdrop)] = MapFlyoutBackdrop,
[nameof(Shell.FlyoutFooter)] = MapFlyoutFooter,
Expand Down
Expand Up @@ -17,6 +17,30 @@ namespace Microsoft.Maui.DeviceTests
{
public partial class ShellTests : ControlsHandlerTestBase
{
[Fact]
public async Task FlyoutContentUpdatesAfterChange()
{
var flyoutContent = new VerticalStackLayout()
{
new Label() { Text = "Flyout Content" }
};

await RunShellTest(shell =>
{
shell.FlyoutBehavior = FlyoutBehavior.Locked;
},
async (shell, handler) =>
{
Assert.False(flyoutContent.IsLoaded);
shell.FlyoutContent = flyoutContent;
await OnLoadedAsync(flyoutContent);
shell.FlyoutContent = null;
await OnUnloadedAsync(flyoutContent);
});
}

#if !MACCATALYST
[Fact]
public async Task LogicalChildrenPropagateCorrectly()
Expand Down Expand Up @@ -303,6 +327,8 @@ Thickness GetSafeArea()
return Thickness.Zero;
#endif
}
#endif

async Task RunShellTest(Action<Shell> action, Func<Shell, ShellHandler, Task> testAction)
{
SetupBuilder();
Expand All @@ -319,6 +345,5 @@ async Task RunShellTest(Action<Shell> action, Func<Shell, ShellHandler, Task> te
await testAction(shell, handler);
});
}
#endif
}
}

0 comments on commit bb8a913

Please sign in to comment.