Skip to content

Commit

Permalink
Fix: Fixed xamlRoot in the ConsentDialog (files-community#14013)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 authored Nov 21, 2023
1 parent 494153c commit 79855ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/Files.App/Views/HomePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Dialogs;
using Files.App.UserControls.Widgets;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using System.IO;
using System.Runtime.InteropServices;
using Windows.Foundation.Metadata;
using Windows.Storage;

namespace Files.App.Views
Expand Down Expand Up @@ -53,8 +53,8 @@ private void ViewModel_WidgetListRefreshRequestedInvoked(object? sender, EventAr
public void ReloadWidgets()
{
quickAccessWidget = WidgetsHelpers.TryGetWidget(UserSettingsService.GeneralSettingsService, Widgets.ViewModel, out bool shouldReloadQuickAccessWidget, quickAccessWidget);
drivesWidget = WidgetsHelpers.TryGetWidget(UserSettingsService.GeneralSettingsService, Widgets.ViewModel, out bool shouldReloadDrivesWidget, drivesWidget);
fileTagsWidget = WidgetsHelpers.TryGetWidget(UserSettingsService.GeneralSettingsService, Widgets.ViewModel, out bool shouldReloadFileTags, fileTagsWidget);
drivesWidget = WidgetsHelpers.TryGetWidget(UserSettingsService.GeneralSettingsService, Widgets.ViewModel, out bool shouldReloadDrivesWidget, drivesWidget);
fileTagsWidget = WidgetsHelpers.TryGetWidget(UserSettingsService.GeneralSettingsService, Widgets.ViewModel, out bool shouldReloadFileTags, fileTagsWidget);
recentFilesWidget = WidgetsHelpers.TryGetWidget(UserSettingsService.GeneralSettingsService, Widgets.ViewModel, out bool shouldReloadRecentFiles, recentFilesWidget);

// Reload QuickAccessWidget
Expand Down Expand Up @@ -143,7 +143,11 @@ private async void RecentFilesWidget_RecentFileInvoked(object sender, PathNaviga
}
catch (UnauthorizedAccessException)
{
DynamicDialog dialog = DynamicDialogFactory.GetFor_ConsentDialog();
var dialog = DynamicDialogFactory.GetFor_ConsentDialog();

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

await dialog.TryShowAsync();
}
catch (COMException) { }
Expand Down
7 changes: 6 additions & 1 deletion src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Navigation;
using System.Runtime.CompilerServices;
using Windows.Foundation.Metadata;
using Windows.System;
using Windows.UI.Core;
using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
Expand Down Expand Up @@ -702,7 +703,11 @@ protected async Task DisplayFilesystemConsentDialogAsync()
await DispatcherQueue.EnqueueOrInvokeAsync(async () =>
{
var dialog = DynamicDialogFactory.GetFor_ConsentDialog();
await SetContentDialogRoot(dialog).ShowAsync(ContentDialogPlacement.Popup);

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

await dialog.ShowAsync();
});
}
}
Expand Down

0 comments on commit 79855ba

Please sign in to comment.