-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fixed the text and icon color issues in the DatePicker when hovering over it. #27147
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using System.ComponentModel; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Maui.Graphics; | ||
| using Microsoft.Maui.Handlers; | ||
| using Microsoft.Maui.Platform; | ||
| using Microsoft.UI.Xaml.Controls; | ||
| using Xunit; | ||
| using WSolidColorBrush = Microsoft.UI.Xaml.Media.SolidColorBrush; | ||
|
|
||
| namespace Microsoft.Maui.DeviceTests; | ||
|
|
||
| public partial class DatePickerTests | ||
| { | ||
| [Fact] | ||
| [Description("The DatePicker Text and Icon Color should work properly on PointerOver")] | ||
| public async Task DatePickerTextAndIconColorShouldWorkProperlyOnPointerOver() | ||
| { | ||
| SetupBuilder(); | ||
|
|
||
| var datePicker = new Controls.DatePicker | ||
| { | ||
| TextColor = Colors.Red | ||
| }; | ||
| var expectedValue = datePicker.TextColor; | ||
|
|
||
| var handler = await CreateHandlerAsync<DatePickerHandler>(datePicker); | ||
| var platformView = GetPlatformControl(handler); | ||
|
|
||
| await InvokeOnMainThreadAsync(() => | ||
| { | ||
| var foregroundPointerOverBrush = platformView.Resources["CalendarDatePickerTextForegroundPointerOver"] as WSolidColorBrush; | ||
| var foregroundPointerOverColor = foregroundPointerOverBrush.Color.ToColor(); | ||
| Assert.Equal(expectedValue, foregroundPointerOverColor); | ||
|
|
||
| var glyphForegroundPointerOverBrush = platformView.Resources["CalendarDatePickerCalendarGlyphForegroundPointerOver"] as WSolidColorBrush; | ||
| var glyphForegroundPointerOverColor = glyphForegroundPointerOverBrush.Color.ToColor(); | ||
| Assert.Equal(expectedValue, glyphForegroundPointerOverColor); | ||
| }); | ||
| } | ||
|
|
||
| static CalendarDatePicker GetPlatformControl(DatePickerHandler handler) => | ||
| handler.PlatformView; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Handlers; | ||
| using Microsoft.Maui.Hosting; | ||
|
|
||
| namespace Microsoft.Maui.DeviceTests; | ||
|
|
||
| [Category(TestCategory.DatePicker)] | ||
| public partial class DatePickerTests : ControlsHandlerTestBase | ||
| { | ||
| void SetupBuilder() | ||
| { | ||
| EnsureHandlerCreated(builder => | ||
| { | ||
| builder.ConfigureMauiHandlers(handlers => | ||
| { | ||
| handlers.AddHandler<DatePicker, DatePickerHandler>(); | ||
| }); | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue22987"> | ||
| <ContentPage.Resources> | ||
| <Style TargetType="DatePicker"> | ||
| <Setter Property="VisualStateManager.VisualStateGroups"> | ||
| <VisualStateGroupList> | ||
| <VisualStateGroup Name="CommonStates"> | ||
| <VisualState Name="Normal"> | ||
| <VisualState.Setters> | ||
| <Setter Property="TextColor" Value="white" /> | ||
| </VisualState.Setters> | ||
| </VisualState> | ||
|
|
||
| <VisualState Name="PointerOver"> | ||
| <VisualState.Setters> | ||
| <Setter Property="TextColor" Value="yellow" /> | ||
| </VisualState.Setters> | ||
| </VisualState> | ||
| </VisualStateGroup> | ||
| </VisualStateGroupList> | ||
| </Setter> | ||
| </Style> | ||
| </ContentPage.Resources> | ||
|
|
||
| <VerticalStackLayout VerticalOptions="Center" HorizontalOptions="Center"> | ||
| <Label Text="DatePicker" AutomationId="Label"/> | ||
| <DatePicker BackgroundColor="Black" Date="01/15/2025" /> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 22987, "DatePicker Color Icon", PlatformAffected.UWP)] | ||
| public partial class Issue22987 : ContentPage | ||
| { | ||
| public Issue22987() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_IOS | ||
| // In MacCatalyst, DatePicker Text color property is not working MacOS https://github.com/dotnet/maui/issues/20904 | ||
| // In Windows, Once this PR https://github.com/dotnet/maui/pull/27477 merged, we can implement the MoveCursor and enable the test | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue22987 : _IssuesUITest | ||
| { | ||
| public Issue22987(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "DatePicker Color Icon"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.DatePicker)] | ||
| public void DatePickerTextandIconColorShouldWorkProperlyOnPointerOver() | ||
| { | ||
| App.WaitForElement("Label"); | ||
|
|
||
| //need to include something like a MovePointer and MovePointerToCoordinate methods for hovering. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The image is incorrect. I have restricted the test for now. Once implementation PR #27477 is merged, we can add
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| #endif | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have done tests with different approaches:
Using the Hover command https://github.com/appium/appium-windows-driver?tab=readme-ov-file#windows-hover is not available in the used version:
Trying to move the cursor fails because using PointerKind.Mouse:
OpenQA.Selenium.WebDriverException: 'Currently only pen and touch pointer input source types are supported'Can give a way to move the cursor using Win32, but want to test more options.
So, for now, can avoid the test, or use a Device Test to verify the color in the added resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your response. I have looked into the device test for the DatePicker hovering test case but couldn't find any relevant references for it. Could you please share any related references for hovering testcase if available, or can we avoid this test for now? @jsuarezruiz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @mattleibow has a PR here that provides this behavior
#27477