Skip to content

Fix: Always set content dialog root #13859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Files.App.Dialogs;
using Microsoft.UI.Xaml.Controls;
using Windows.Foundation.Metadata;

namespace Files.App.Actions
{
Expand Down Expand Up @@ -30,6 +31,9 @@ public override async Task ExecuteAsync()
FileName = fileName,
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

var result = await dialog.TryShowAsync();

if (!dialog.CanCreate || result != ContentDialogResult.Primary)
Expand Down
4 changes: 4 additions & 0 deletions src/Files.App/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.UI.Xaml.Controls;
using System.IO;
using System.Net.Http;
using Windows.Foundation.Metadata;
using Windows.Services.Store;
using Windows.Storage;
using WinRT.Interop;
Expand Down Expand Up @@ -146,6 +147,9 @@ private static async Task<bool> ShowDialogAsync()
PrimaryButtonText = "ConsentDialogPrimaryButtonText".GetLocalizedResource()
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

ContentDialogResult result = await dialog.TryShowAsync();

return result == ContentDialogResult.Primary;
Expand Down
10 changes: 10 additions & 0 deletions src/Files.App/Utils/Archives/DecompressHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using SevenZip;
using System.IO;
using System.Text;
using Windows.Foundation.Metadata;
using Windows.Storage;

namespace Files.App.Utils.Archives
Expand Down Expand Up @@ -145,6 +146,9 @@ public static async Task DecompressArchiveAsync(IShellPage associatedInstance)
};
decompressArchiveDialog.ViewModel = decompressArchiveViewModel;

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
decompressArchiveDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

ContentDialogResult option = await decompressArchiveDialog.TryShowAsync();
if (option != ContentDialogResult.Primary)
return;
Expand Down Expand Up @@ -196,6 +200,9 @@ public static async Task DecompressArchiveHereAsync(IShellPage associatedInstanc

decompressArchiveDialog.ViewModel = decompressArchiveViewModel;

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
decompressArchiveDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

ContentDialogResult option = await decompressArchiveDialog.TryShowAsync();
if (option != ContentDialogResult.Primary)
return;
Expand Down Expand Up @@ -233,6 +240,9 @@ public static async Task DecompressArchiveToChildFolderAsync(IShellPage associat
};
decompressArchiveDialog.ViewModel = decompressArchiveViewModel;

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
decompressArchiveDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

ContentDialogResult option = await decompressArchiveDialog.TryShowAsync();
if (option != ContentDialogResult.Primary)
return;
Expand Down
9 changes: 8 additions & 1 deletion src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.UI.Xaml.Controls;
using System.Text.RegularExpressions;
using Vanara.PInvoke;
using Windows.Foundation.Metadata;
using Windows.Storage;

namespace Files.App.Utils.RecycleBin
Expand All @@ -25,7 +26,7 @@ public static ulong GetSize()
{
return (ulong)Win32Shell.QueryRecycleBin().BinSize;
}

public static async Task<bool> IsRecycleBinItem(IStorageItem item)
{
List<ShellFileItem> recycleBinItems = await EnumerateRecycleBin();
Expand Down Expand Up @@ -55,6 +56,9 @@ public static async Task EmptyRecycleBinAsync()
DefaultButton = ContentDialogButton.Primary
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
ConfirmEmptyBinDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

// If the operation is approved by the user
if (userSettingsService.FoldersSettingsService.DeleteConfirmationPolicy is DeleteConfirmationPolicies.Never ||
await ConfirmEmptyBinDialog.TryShowAsync() == ContentDialogResult.Primary)
Expand Down Expand Up @@ -103,6 +107,9 @@ public static async Task RestoreSelectionRecycleBinAsync(IShellPage associatedIn
DefaultButton = ContentDialogButton.Primary
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
ConfirmEmptyBinDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

ContentDialogResult result = await ConfirmEmptyBinDialog.TryShowAsync();

if (result == ContentDialogResult.Primary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.UI.Xaml.Controls;
using System.IO;
using System.Text;
using Windows.Foundation.Metadata;
using Windows.Storage;

namespace Files.App.Utils.Storage
Expand Down Expand Up @@ -146,6 +147,9 @@ await DialogDisplayHelper.ShowDialogAsync(
CloseButtonText = "Cancel".GetLocalizedResource()
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

ContentDialogResult result = await dialog.TryShowAsync();

if (result == ContentDialogResult.Primary)
Expand Down Expand Up @@ -345,6 +349,9 @@ await DialogDisplayHelper.ShowDialogAsync(
CloseButtonText = "Cancel".GetLocalizedResource()
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
dialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

ContentDialogResult result = await dialog.TryShowAsync();

if (result == ContentDialogResult.Primary)
Expand Down
4 changes: 4 additions & 0 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.UI.Xaml.Navigation;
using System.Runtime.CompilerServices;
using Windows.ApplicationModel;
using Windows.Foundation.Metadata;
using Windows.Services.Store;
using WinRT.Interop;
using VirtualKey = Windows.System.VirtualKey;
Expand Down Expand Up @@ -78,6 +79,9 @@ private async Task PromptForReviewAsync()
SecondaryButtonText = "No".ToLocalized()
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
promptForReviewDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;

var result = await promptForReviewDialog.TryShowAsync();

if (result == ContentDialogResult.Primary)
Expand Down