Skip to content

Commit

Permalink
fix: Hide open flyouts when MessageDialog is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Sep 22, 2021
1 parent ecbbe90 commit 0b00af4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Uno.UI/UI/Xaml/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static Application()
ApiInformation.RegisterAssembly(typeof(Application).Assembly);
ApiInformation.RegisterAssembly(typeof(Windows.Storage.ApplicationData).Assembly);

Uno.DispatcherTimerHelper.SetDispatcherTimerGetter(() => new DispatcherTimer());
Uno.Helpers.DispatcherTimerProxy.SetDispatcherTimerGetter(() => new DispatcherTimer());
Uno.Helpers.VisualTreeHelperProxy.SetCloseAllPopupsAction(() => Media.VisualTreeHelper.CloseAllPopups());

InitializePartialStatic();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#nullable enable

using System;
using System.Collections.Generic;
using System.Text;

namespace Uno
namespace Uno.Helpers
{
internal static class DispatcherTimerHelper
internal static class DispatcherTimerProxy
{
private static Func<IDispatcherTimer>? _getter;

Expand Down
15 changes: 15 additions & 0 deletions src/Uno.UWP/Helpers/VisualTreeHelperProxy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#nullable enable

using System;

namespace Uno.Helpers
{
internal static class VisualTreeHelperProxy
{
private static Action? _closeAllPopups;

public static void CloseAllPopups() => _closeAllPopups?.Invoke();

public static void SetCloseAllPopupsAction(Action closeAllPopups) => _closeAllPopups = closeAllPopups;
}
}
3 changes: 3 additions & 0 deletions src/Uno.UWP/UI/Popups/MessageDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Uno.Helpers;
using Windows.Foundation;
using Windows.UI.Core;

Expand Down Expand Up @@ -52,6 +53,8 @@ public MessageDialog(string content, string title)

public IAsyncOperation<IUICommand> ShowAsync()
{
VisualTreeHelperProxy.CloseAllPopups();

var invokedCommand = new TaskCompletionSource<IUICommand>();

return AsyncOperation.FromTask<IUICommand>(async ct =>
Expand Down

0 comments on commit 0b00af4

Please sign in to comment.