Skip to content
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

fix(ColorPicker): ToolTip of ColorPickerSlider doesn't work properly #13912

Closed
Closed
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
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using SamplesApp.UITests.TestFramework;
using Uno.UITest;
using Uno.UITest.Helpers;
using Uno.UITest.Helpers.Queries;
using Uno.UITests.Helpers;
using Query = System.Func<Uno.UITest.IAppQuery, Uno.UITest.IAppQuery>;

namespace SamplesApp.UITests.Microsoft_UI_Xaml_Controls.ColorPickerTests
{
public partial class Given_ColorPicker : SampleControlUITestBase
{
[Test]
[AutoRetry]
public void When_Add_And_Remove_From_VisualTree()
{
Run("UITests.Microsoft_UI_Xaml_Controls.ColorPickerTests.ColorPickerInElevatedView", skipInitialScreenshot: true);

var focusButton = _app.Marked("focus");
var openButton = _app.Marked("open");
var closeButton = _app.Marked("close");
_app.Tap(focusButton);
var before = _app.Screenshot("before");

_app.Tap(openButton);
_app.WaitForElement(closeButton);
_app.Tap(closeButton);
_app.WaitForNoElement(closeButton);
_app.Tap(focusButton);
var after = _app.Screenshot("after");

ImageAssert.AreEqual(before, after);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Uno.UI.Samples.Controls;
using Uno.UI.Toolkit;
using Windows.UI.Xaml.Controls;

namespace UITests.Microsoft_UI_Xaml_Controls.ColorPickerTests
{
[Sample("ColorPicker", "MUX", "ColorPickerInElevatedView")]
public sealed partial class ColorPickerInElevatedView : Page
{
public ColorPickerInElevatedView()
{
Button openButton = new Button
{
Content = "open",
Name = "open"
};
Button closeButton = new Button
{
Content = "close",
Name = "close"
};
ElevatedView view = new ElevatedView
{
ElevatedContent = new StackPanel
{
Children =
{
closeButton,
new Microsoft.UI.Xaml.Controls.ColorPicker
{
IsAlphaEnabled = true,
}
}
}
};

Content = new StackPanel
{
Children =
{
new Button
{
Content = "focus",
Name = "focus",
},
openButton,
}
};

openButton.Click += (s, e) =>
{
var panel = Content as StackPanel;
if (panel is StackPanel)
{
if (panel.Children.IndexOf(view) < 0)
panel.Children.Add(view);
}
};

closeButton.Click += (s, e) =>
{
var panel = Content as StackPanel;
if (panel is StackPanel)
{
if (panel.Children.IndexOf(view) >= 0)
panel.Children.Remove(view);
}
};
}
}
}
1 change: 1 addition & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -5226,6 +5226,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\ColorPickerTests\ColorPickerSample.xaml.cs">
<DependentUpon>ColorPickerSample.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\ColorPickerTests\ColorPickerInElevatedView.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\ColorPickerTests\WinUIColorPickerPage.xaml.cs">
<DependentUpon>WinUIColorPickerPage.xaml</DependentUpon>
</Compile>
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Controls/ToolTip/ToolTip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private Size GetTooltipSize()
private void OnOpenChanged(bool isOpen)
{
PerformPlacementInternal();
if (_owner is not null)
if (_owner is not null && Popup.XamlRoot is null)
{
XamlRoot = XamlRoot.GetForElement(_owner);
Popup.XamlRoot = XamlRoot.GetForElement(_owner);
Expand Down
Loading