Skip to content

Commit

Permalink
fix(flyout): Fix NRE from trying to close uncreated Popup in Flyout
Browse files Browse the repository at this point in the history
Flyout.Close() is called when an owning Button is unloaded, which was resulting in an NRE if the Flyout had never been shown.
  • Loading branch information
davidjohnoliver committed Apr 27, 2020
1 parent db1fba4 commit 18f0191
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Private.Infrastructure;
using Windows.UI.Xaml.Controls;

namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls
{
[TestClass]
public class Given_Flyout
{
[TestMethod]
[RunsOnUIThread]
public async Task When_Unloaded_Before_Shown()
{
var button = new Button()
{
Flyout = new Flyout
{
Content = new Border { Width = 50, Height = 30 }
}
};

TestServices.WindowHelper.WindowContent = button;

await TestServices.WindowHelper.WaitForIdle();

TestServices.WindowHelper.WindowContent = null;

await TestServices.WindowHelper.WaitForIdle();
}
}
}
5 changes: 4 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/Flyout/FlyoutBase.cs
Expand Up @@ -264,7 +264,10 @@ private void OnPopupClosed(object sender, object e)

protected internal virtual void Close()
{
_popup.IsOpen = false;
if (_popup != null)
{
_popup.IsOpen = false;
}
}

protected internal virtual void Open()
Expand Down

0 comments on commit 18f0191

Please sign in to comment.