Skip to content

Commit 3e47d80

Browse files
committed
Switch to MUX:CommandBarFlyout in XAML Islands proofing menu
This fixes the broken keyboard navigation in an islands app, however it can cause a crash when using WinUI 2.6 (but is fixed in WinUI 2.7). Closes microsoft#8306
1 parent d59110a commit 3e47d80

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ struct CustomAppBarButton : xaml::Controls::AppBarButtonT<CustomAppBarButton> {
3030
}
3131
};
3232

33-
void FixProofingMenuCrashForXamlIsland(xaml::Controls::TextCommandBarFlyout const &flyout) {
33+
void FixProofingMenuCrashForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout) {
3434
flyout.Opening([](winrt::IInspectable const &sender, auto &&) {
35-
const auto &flyout = sender.as<xaml::Controls::TextCommandBarFlyout>();
35+
const auto &flyout = sender.as<winrt::Microsoft::UI::Xaml::Controls::TextCommandBarFlyout>();
3636
if (const auto &textBox = flyout.Target().try_as<xaml::Controls::TextBox>()) {
3737
const auto &commands = flyout.SecondaryCommands();
3838
for (uint32_t i = 0; i < commands.Size(); ++i) {

vnext/Microsoft.ReactNative/Utils/XamlIslandUtils.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
#include <UI.Xaml.Controls.Primitives.h>
99
#include <UI.Xaml.Controls.h>
1010

11+
#include <winrt/Microsoft.UI.Xaml.Controls.h>
12+
1113
namespace Microsoft::ReactNative {
1214

13-
void FixProofingMenuCrashForXamlIsland(xaml::Controls::TextCommandBarFlyout const &flyout);
15+
void FixProofingMenuCrashForXamlIsland(xaml::Controls::Primitives::FlyoutBase const &flyout);
1416

1517
template <typename T>
1618
inline void EnsureUniqueTextFlyoutForXamlIsland(T const &textView) {
@@ -19,7 +21,7 @@ inline void EnsureUniqueTextFlyoutForXamlIsland(T const &textView) {
1921
// to show the flyout on other windows cause the first window to get focus.
2022
// https://github.com/microsoft/microsoft-ui-xaml/issues/5341
2123
if (IsXamlIsland()) {
22-
xaml::Controls::TextCommandBarFlyout flyout;
24+
winrt::Microsoft::UI::Xaml::Controls::TextCommandBarFlyout flyout;
2325
flyout.Placement(xaml::Controls::Primitives::FlyoutPlacementMode::BottomEdgeAlignedLeft);
2426

2527
// This works around a XAML Islands bug where the Proofing sub-menu for

0 commit comments

Comments
 (0)