Skip to content

Commit 8f1c7b2

Browse files
authored
Merge pull request #22312 from unoplatform/dev/mazi/context-menu-tb
2 parents 14131bb + 33739e9 commit 8f1c7b2

File tree

47 files changed

+2333
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2333
-363
lines changed

src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Shapes/Basics_Shapes_Tests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void When_Polygon()
6969
[AutoRetry]
7070
[ActivePlatforms(Platform.iOS)]
7171
[Timeout(TestTimeout)]
72+
[Ignore("Flaky on iOS/Android native https://github.com/unoplatform/uno/issues/22688")]
7273
public void When_Path()
7374
{
7475
// For Path, the junction between the begin and the end of the path is not as smooth as WinUI (on iOS),

src/SamplesApp/UITests.Shared/Microsoft_UI_Xaml_Controls/CommandBarFlyoutTests/TextCommandBarFlyoutPage.xaml.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,32 @@
2121

2222
namespace MUXControlsTestApp;
2323

24+
// RichEditBox and RichTextBlock code is commented out because Uno does not yet fully
25+
// support these controls (tracked by GitHub issue #81).
26+
// Re-enable the commented-out sections below when RichEditBox and RichTextBlock gain
27+
// support for ContextFlyout, SelectionFlyout, and text selection operations.
28+
2429
[Sample("CommandBarFlyout", "WinUI")]
2530
public sealed partial class TextCommandBarFlyoutPage : TestPage
2631
{
2732
public TextCommandBarFlyoutPage()
2833
{
2934
this.InitializeComponent();
3035

31-
RichEditBox1.Document.SetText(TextSetOptions.None, "Lorem ipsum ergo sum");
36+
//RichEditBox1.Document.SetText(TextSetOptions.None, "Lorem ipsum ergo sum");
3237
Clipboard.ContentChanged += OnClipboardContentChanged;
3338

3439
TextControlContextFlyout.Placement = FlyoutPlacementMode.BottomEdgeAlignedLeft;
3540
TextControlSelectionFlyout.Placement = FlyoutPlacementMode.TopEdgeAlignedLeft;
3641
TextBox1.ContextFlyout = TextControlContextFlyout;
3742
TextBlock1.ContextFlyout = TextControlContextFlyout;
38-
RichEditBox1.ContextFlyout = TextControlContextFlyout;
39-
RichTextBlock1.ContextFlyout = TextControlContextFlyout;
43+
//RichEditBox1.ContextFlyout = TextControlContextFlyout;
44+
//RichTextBlock1.ContextFlyout = TextControlContextFlyout;
4045
PasswordBox1.ContextFlyout = TextControlContextFlyout;
4146
TextBox1.SelectionFlyout = TextControlSelectionFlyout;
4247
TextBlock1.SelectionFlyout = TextControlSelectionFlyout;
43-
RichEditBox1.SelectionFlyout = TextControlSelectionFlyout;
44-
RichTextBlock1.SelectionFlyout = TextControlSelectionFlyout;
48+
//RichEditBox1.SelectionFlyout = TextControlSelectionFlyout;
49+
//RichTextBlock1.SelectionFlyout = TextControlSelectionFlyout;
4550
PasswordBox1.SelectionFlyout = TextControlSelectionFlyout;
4651
}
4752

@@ -90,12 +95,12 @@ private void OnTextBlockSelectAllClicked(object sender, object args)
9095

9196
private void OnRichEditBoxSelectAllClicked(object sender, object args)
9297
{
93-
RichEditBox1.Document.Selection.Expand(TextRangeUnit.Story);
98+
//RichEditBox1.Document.Selection.Expand(TextRangeUnit.Story);
9499
}
95100

96101
private void OnRichTextBlockSelectAllClicked(object sender, object args)
97102
{
98-
RichTextBlock1.SelectAll();
103+
//RichTextBlock1.SelectAll();
99104
}
100105

101106
private void OnTextBoxClearSelectionClicked(object sender, object args)
@@ -110,7 +115,7 @@ private void OnTextBlockClearSelectionClicked(object sender, object args)
110115

111116
private void OnRichEditBoxClearSelectionClicked(object sender, object args)
112117
{
113-
RichEditBox1.Document.Selection.Collapse(true);
118+
//RichEditBox1.Document.Selection.Collapse(true);
114119
}
115120

116121
private void OnTextBoxFillWithTextClicked(object sender, object args)
@@ -120,12 +125,12 @@ private void OnTextBoxFillWithTextClicked(object sender, object args)
120125

121126
private void OnRichEditBoxFillWithTextClicked(object sender, object args)
122127
{
123-
RichEditBox1.Document.SetText(TextSetOptions.None, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
128+
//RichEditBox1.Document.SetText(TextSetOptions.None, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
124129
}
125130

126131
private void OnRichTextBlockClearSelectionClicked(object sender, object args)
127132
{
128-
RichTextBlock1.Select(RichTextBlock1.ContentStart, RichTextBlock1.ContentStart);
133+
//RichTextBlock1.Select(RichTextBlock1.ContentStart, RichTextBlock1.ContentStart);
129134
}
130135

131136
private void OnShowTextControlFlyoutOnTextBoxClicked(object sender, object args)
@@ -140,12 +145,12 @@ private void OnShowTextControlFlyoutOnTextBlockClicked(object sender, object arg
140145

141146
private void OnShowTextControlFlyoutOnRichEditBoxClicked(object sender, object args)
142147
{
143-
ShowTextControlContextFlyoutTransient(RichEditBox1);
148+
//ShowTextControlContextFlyoutTransient(RichEditBox1);
144149
}
145150

146151
private void OnShowTextControlFlyoutOnRichTextBlockClicked(object sender, object args)
147152
{
148-
ShowTextControlContextFlyoutTransient(RichTextBlock1);
153+
//ShowTextControlContextFlyoutTransient(RichTextBlock1);
149154
}
150155

151156
private void OnShowTextControlFlyoutOnPasswordBoxClicked(object sender, object args)
@@ -165,12 +170,12 @@ private void OnShowStandardTextControlFlyoutOnTextBlockClicked(object sender, ob
165170

166171
private void OnShowStandardTextControlFlyoutOnRichEditBoxClicked(object sender, object args)
167172
{
168-
ShowTextControlContextFlyoutStandard(RichEditBox1);
173+
//ShowTextControlContextFlyoutStandard(RichEditBox1);
169174
}
170175

171176
private void OnShowStandardTextControlFlyoutOnRichTextBlockClicked(object sender, object args)
172177
{
173-
ShowTextControlContextFlyoutStandard(RichTextBlock1);
178+
//ShowTextControlContextFlyoutStandard(RichTextBlock1);
174179
}
175180

176181
private void OnShowStandardTextControlFlyoutOnPasswordBoxClicked(object sender, object args)

src/Uno.UI.FluentTheme.v2/Resources/Version2/Priority02/PasswordBox_themeresources.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
2323
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
2424
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}" />
25-
<!-- Uno TODO: TextCommandBarFlyout isn't implemented but ContextFlyout is mapped to long-press on some platforms, causing an undismissable invisible popup to appear #12165 -->
26-
<!--<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />-->
25+
<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />
2726
<Setter Property="SelectionFlyout" Value="{StaticResource TextControlCommandBarSelectionFlyout}" />
2827
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
2928
<Setter Property="Template">

src/Uno.UI.FluentTheme.v2/Resources/Version2/Priority02/TextBox_themeresources.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@
200200
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
201201
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}" />
202202
<Setter Property="UseSystemFocusVisuals" Value="{ThemeResource IsApplicationFocusVisualKindReveal}" />
203-
<!-- Uno TODO: TextCommandBarFlyout isn't implemented but ContextFlyout is mapped to long-press on some platforms, causing an undismissable invisible popup to appear #12165 -->
204-
<!--<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />-->
203+
<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />
205204
<Setter Property="SelectionFlyout" Value="{StaticResource TextControlCommandBarSelectionFlyout}" />
206205
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
207206
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />

src/Uno.UI.FluentTheme.v2/themeresources_v2.xaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6613,8 +6613,7 @@
66136613
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
66146614
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
66156615
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}" />
6616-
<!-- Uno TODO: TextCommandBarFlyout isn't implemented but ContextFlyout is mapped to long-press on some platforms, causing an undismissable invisible popup to appear #12165 -->
6617-
<!--<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />-->
6616+
<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />
66186617
<Setter Property="SelectionFlyout" Value="{StaticResource TextControlCommandBarSelectionFlyout}" />
66196618
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
66206619
<Setter Property="Template">
@@ -9337,8 +9336,7 @@
93379336
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
93389337
<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}" />
93399338
<Setter Property="UseSystemFocusVisuals" Value="{ThemeResource IsApplicationFocusVisualKindReveal}" />
9340-
<!-- Uno TODO: TextCommandBarFlyout isn't implemented but ContextFlyout is mapped to long-press on some platforms, causing an undismissable invisible popup to appear #12165 -->
9341-
<!--<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />-->
9339+
<Setter Property="ContextFlyout" Value="{StaticResource TextControlCommandBarContextFlyout}" />
93429340
<Setter Property="SelectionFlyout" Value="{StaticResource TextControlCommandBarSelectionFlyout}" />
93439341
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
93449342
<Setter Property="BackgroundSizing" Value="InnerBorderEdge" />

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,70 @@ public enum VerticalPosition
19951995
BottomFlush,
19961996
BeyondBottom
19971997
}
1998+
1999+
2000+
#if HAS_UNO
2001+
[TestMethod]
2002+
[RunsOnUIThread]
2003+
public async Task When_Shared_ContextFlyout_Opened_In_Second_Window()
2004+
{
2005+
if (!Uno.UI.Xaml.Controls.NativeWindowFactory.SupportsMultipleWindows)
2006+
{
2007+
Assert.Inconclusive("This test can only run in an environment with multiwindow support");
2008+
}
2009+
2010+
// Use a single shared flyout instance (simulates the singleton
2011+
// TextControlCommandBarContextFlyout resource in Generic.xaml).
2012+
var sharedFlyout = new Flyout
2013+
{
2014+
Content = new TextBlock { Text = "Shared" }
2015+
};
2016+
2017+
// --- Window 1: open and close the flyout ---
2018+
var button1 = new Button { Content = "W1" };
2019+
button1.ContextFlyout = sharedFlyout;
2020+
TestServices.WindowHelper.WindowContent = button1;
2021+
await TestServices.WindowHelper.WaitForLoaded(button1);
2022+
2023+
try
2024+
{
2025+
sharedFlyout.ShowAt(button1);
2026+
await TestServices.WindowHelper.WaitForIdle();
2027+
Assert.IsTrue(sharedFlyout.IsOpen, "Flyout should be open in window 1");
2028+
}
2029+
finally
2030+
{
2031+
sharedFlyout.Hide();
2032+
await TestServices.WindowHelper.WaitForIdle();
2033+
}
2034+
2035+
// --- Window 2: open the same flyout on a different target ---
2036+
var window2 = new Window();
2037+
try
2038+
{
2039+
var button2 = new Button { Content = "W2" };
2040+
button2.ContextFlyout = sharedFlyout;
2041+
window2.Content = button2;
2042+
2043+
bool activated = false;
2044+
window2.Activated += (s, e) => activated = true;
2045+
window2.Activate();
2046+
await TestServices.WindowHelper.WaitFor(() => activated);
2047+
await TestServices.WindowHelper.WaitForLoaded(button2);
2048+
2049+
// This must not throw InvalidOperationException("Cannot change XamlRoot for existing element")
2050+
sharedFlyout.ShowAt(button2);
2051+
await TestServices.WindowHelper.WaitForIdle();
2052+
2053+
Assert.IsTrue(sharedFlyout.IsOpen, "Flyout should be open in window 2");
2054+
}
2055+
finally
2056+
{
2057+
sharedFlyout.Hide();
2058+
window2.Close();
2059+
}
2060+
}
2061+
#endif
19982062
}
19992063

20002064
public partial class MyMenuFlyout : MenuFlyout

0 commit comments

Comments
 (0)