Skip to content

Commit db35381

Browse files
Merge pull request #21243 from unoplatform/dev/mazi/cbf-secondary-state
2 parents 8483cb7 + 7437bb6 commit db35381

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_FrameworkElement_And_Leak.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public class Given_FrameworkElement_And_Leak
183183
#endif
184184
, RuntimeTestPlatforms.SkiaUIKit | RuntimeTestPlatforms.NativeUIKit)] // UIKit Disabled - #10344
185185
[DataRow(typeof(MediaPlayerElement), 15)]
186-
[DataRow("Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls.CommandBarFlyout_Leak", 15)]
186+
[DataRow("Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml.Controls.CommandBarFlyout_Leak", 15, LeakTestStyles.All, RuntimeTestPlatforms.NativeUIKit)] // flaky on native iOS
187187
public async Task When_Add_Remove(object controlTypeRaw, int count, LeakTestStyles leakTestStyles = LeakTestStyles.All, RuntimeTestPlatforms ignoredPlatforms = RuntimeTestPlatforms.None)
188188
{
189189
if (ignoredPlatforms.HasFlag(RuntimeTestsPlatformHelper.CurrentPlatform))

src/Uno.UI/UI/Xaml/Controls/CommandBarFlyout/CommandBarFlyout.mux.cs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
// MUX Reference controls\dev\CommandBarFlyout\CommandBarFlyout.cpp, tag winui3/release/1.7.3, commit 65718e2813a90fc900e8775d2ddc580b268fcc2f
44

55
using System;
6+
using System.Numerics;
7+
using Microsoft.UI.Xaml.Automation.Peers;
68
using Microsoft.UI.Xaml.Controls.Primitives;
9+
using Microsoft.UI.Xaml.Media;
710
using Uno.Disposables;
811
using Uno.UI.DataBinding;
912
using Uno.UI.Helpers.WinUI;
1013
using Windows.Foundation.Collections;
11-
using Microsoft.UI.Xaml;
12-
using Microsoft.UI.Xaml.Automation.Peers;
13-
using Microsoft.UI.Xaml.Controls;
14-
using Microsoft.UI.Xaml.Media;
1514
using static Microsoft.UI.Xaml.Controls._Tracing;
1615
using CommandBarFlyoutCommandBar = Microsoft.UI.Xaml.Controls.Primitives.CommandBarFlyoutCommandBar;
17-
using System.Numerics;
1816

1917
namespace Microsoft.UI.Xaml.Controls;
2018

@@ -195,32 +193,31 @@ void OnSecondaryCommandsChanged(IObservableVector<ICommandBarElement> sender, IV
195193
}
196194

197195
SharedHelpers.QueueCallbackForCompositionRendering(() =>
196+
{
197+
if (commandBar is { } commandBarFlyoutCommandBar)
198198
{
199-
if (commandBar is { } commandBarFlyoutCommandBar)
199+
using var scopeGuard = Disposable.Create(() =>
200200
{
201-
using var scopeGuard = Disposable.Create(() =>
202-
{
203-
commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = false;
204-
});
201+
commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = false;
202+
});
205203

206-
commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = true;
204+
commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = true;
207205

208-
// If we don't have IFlyoutBase5 available, then we assume a standard show mode.
209-
if (ShowMode == FlyoutShowMode.Standard)
210-
{
206+
// If we don't have IFlyoutBase5 available, then we assume a standard show mode.
207+
if (ShowMode == FlyoutShowMode.Standard)
208+
{
211209
#if HAS_UNO
212-
// In case of Uno Platform, the callback is executed too early, before CommandBarFlyoutCommandBar.OnApplyTemplate.
213-
// This causes unexpected behavior https://github.com/unoplatform/uno/issues/20984. To avoid this, we schedule the IsOpen change
214-
// on the next tick.
215-
DispatcherQueue.TryEnqueue(() =>
216-
{
217-
commandBar.IsOpen = true;
218-
});
210+
// In case of Uno Platform, the callback is executed too early, before CommandBarFlyoutCommandBar.OnApplyTemplate.
211+
// This causes unexpected behavior https://github.com/unoplatform/uno/issues/20984. To avoid this, we schedule the IsOpen change
212+
// on the next tick.
213+
DispatcherQueue.TryEnqueue(() =>
214+
{
215+
commandBar.IsOpen = true;
216+
});
219217
#endif
220-
}
221218
}
222219
}
223-
);
220+
});
224221
}
225222

226223
if (m_primaryCommands.Count > 0)

src/Uno.UI/UI/Xaml/Controls/CommandBarFlyout/CommandBarFlyoutCommandBar.mux.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void OnItemLoaded(object? sender, object args)
450450

451451
void OnItemSizeChanged(object? sender, SizeChangedEventArgs args)
452452
{
453-
UpdateItemVisualState(sender as Control, true /* isPrimaryControl */);
453+
UpdateItemVisualState(sender as Control, false /* isPrimaryControl */);
454454
UpdateTemplateSettings();
455455
}
456456
commandAsFE.SizeChanged += OnItemSizeChanged;

0 commit comments

Comments
 (0)