Skip to content

[Windows] Fixed TimePicker CharacterSpacing issue #30533

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SubhikshaSf4851
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Root Cause:

The UpdateCharacterSpacing method didn't apply spacing to the individual text blocks in TimePicker

Description of Change

Enhanced the UpdateCharacterSpacing method to apply CharacterSpacing to individual text blocks (HourTextBlock, MinuteTextBlock, and PeriodTextBlock) within the TimePicker. This ensures the property works correctly even when the control is loaded asynchronously.

Issues Fixed

Fixes #30199

Tested the behaviour in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
beforeFix30199 Screenshot 2025-07-10 155258

Copy link
Contributor

Hey there @@SubhikshaSf4851! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jul 10, 2025
@SubhikshaSf4851 SubhikshaSf4851 marked this pull request as ready for review July 11, 2025 03:52
@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 03:52
@SubhikshaSf4851 SubhikshaSf4851 requested a review from a team as a code owner July 11, 2025 03:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the Windows TimePicker control did not apply character spacing to its internal text blocks when loaded asynchronously. It enhances the UpdateCharacterSpacing extension to defer applying the spacing until after the control is loaded and adds helper methods to target each text block.

  • Applies CharacterSpacing to HourTextBlock, MinuteTextBlock, and PeriodTextBlock when the control is ready.
  • Uses OnLoaded to handle async loading scenarios.
  • Adds UI tests in both HostApp and Shared.Tests to visually verify the fix.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Core/src/Platform/Windows/TimePickerExtensions.cs Enhanced UpdateCharacterSpacing to wait for IsLoaded and apply spacing to each part.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30199.cs Added a UI test that waits for the TimePicker and captures a screenshot.
src/Controls/tests/TestCases.HostApp/Issues/Issue30199.cs Created a HostApp page with a TimePicker configured to demonstrate the fix.
Comments suppressed due to low confidence (2)

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30199.cs:21

  • The UI test currently only waits for the element and takes a screenshot. Consider adding assertions that programmatically verify the CharacterSpacing on the internal TextBlocks or compare pixel spacing to ensure automated validation.
		App.WaitForElement("timePicker");

src/Core/src/Platform/Windows/TimePickerExtensions.cs:23

  • [nitpick] This public extension method lacks XML documentation. Adding a <summary> explaining its purpose and behavior (especially the use of OnLoaded) would improve discoverability and maintainability.
		public static void UpdateCharacterSpacing(this TimePicker platformTimePicker, ITimePicker timePicker)

Comment on lines 42 to 44
SetCharacterSpacingToBlocks(platformTimePicker, "HourTextBlock");
SetCharacterSpacingToBlocks(platformTimePicker, "MinuteTextBlock");
SetCharacterSpacingToBlocks(platformTimePicker, "PeriodTextBlock");
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The part names 'HourTextBlock', 'MinuteTextBlock', and 'PeriodTextBlock' are hardcoded. Consider defining these strings as constants or iterating over a collection to reduce duplication and make future template changes easier to manage.

Suggested change
SetCharacterSpacingToBlocks(platformTimePicker, "HourTextBlock");
SetCharacterSpacingToBlocks(platformTimePicker, "MinuteTextBlock");
SetCharacterSpacingToBlocks(platformTimePicker, "PeriodTextBlock");
// Iterate over part names using an array
string[] partNames = { HourTextBlock, MinuteTextBlock, PeriodTextBlock };
foreach (var partName in partNames)
{
SetCharacterSpacingToBlocks(platformTimePicker, partName);
}

Copilot uses AI. Check for mistakes.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

public void Issue30199TimePickerCharacterSpacingShouldApply()
{
App.WaitForElement("timePicker");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshots, running a build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-datetimepicker DatePicker, TimePicker community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Windows] TimePicker CharacterSpacing Property Not Working on Windows
2 participants