Skip to content

Conversation

@devanathan-vaithiyanathan
Copy link
Contributor

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Jun 10, 2025

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!

Issue Details:

Setting Border.StrokeDashArray to null does not remove the previously applied dash pattern, causing the dashed border to remain visible.

Description of Change

Handled the case where StrokeDashArray is set to null by resetting the native dash pattern to ensure the stroke renders as a solid line.

Issues Fixed

Fixes #29898
Fixes #22326

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
iOS
iOS-BeforeFix.mov
iOS
iOS-AfterFix.mov

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 10, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@devanathan-vaithiyanathan! 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 the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 10, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@devanathan-vaithiyanathan devanathan-vaithiyanathan changed the title [iOS, macOS] Fix StrokeDashArray on Border does not reset when set to null Fix StrokeDashArray on Border does not reset when set to null Jun 11, 2025
@devanathan-vaithiyanathan devanathan-vaithiyanathan marked this pull request as ready for review June 11, 2025 11:45
Copilot AI review requested due to automatic review settings June 11, 2025 11:45
@devanathan-vaithiyanathan devanathan-vaithiyanathan requested a review from a team as a code owner June 11, 2025 11:45
Copy link
Contributor

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 an issue where setting Border.StrokeDashArray to null (or an empty array) did not clear the previously applied dash pattern on iOS and macOS Catalyst. It adds matching logic on Windows and Android platforms and includes a new UI sample and automated tests to verify the behavior.

  • Handle null/empty dash arrays in the iOS MauiCALayer implementation
  • Mirror the “clear dash” logic in Windows and Android renderers
  • Add a sample page and UI tests to confirm both clearing and setting dash patterns

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Core/src/Platform/iOS/MauiCALayer.cs Reset _strokeDash to null when dash array is null or empty
src/Core/src/Platform/Windows/StrokeExtensions.cs Remove early return so null dash arrays propagate to UpdateStrokeDashPattern
src/Core/src/Platform/Windows/BorderExtensions.cs Clear StrokeDashArray on null/empty dash arrays
src/Core/src/Graphics/MauiDrawable.Android.cs Reset _borderPathEffect and clear paint path effect on null/empty
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29898.cs Add UI tests for “Clear” and “Set” dash buttons
src/Controls/tests/TestCases.HostApp/Issues/Issue29898.cs Add sample page with Clear/Set buttons for manual testing
Comments suppressed due to low confidence (2)

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

  • Consider adding a third test that sets StrokeDashArray to an empty collection (new DoubleCollection()) to verify that the empty-array branch also correctly clears the dash pattern.
VerifyScreenshot();

src/Controls/tests/TestCases.HostApp/Issues/Issue29898.cs:19

  • [nitpick] The local variables button and button2 are ambiguous; consider renaming them to clearDashButton and setDashButton for better readability.
var button = new Button

}
else if (borderDashArray is null || borderDashArray.Length == 0)
{
borderPath.StrokeDashArray = null;
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

Assigning StrokeDashArray to null may lead to NullReferenceExceptions when the path renders. It’s safer to call borderPath.StrokeDashArray.Clear() to preserve a valid collection object.

Suggested change
borderPath.StrokeDashArray = null;
if (borderPath.StrokeDashArray == null)
borderPath.StrokeDashArray = new WDoubleCollection();
borderPath.StrokeDashArray.Clear();

Copilot uses AI. Check for mistakes.
_borderPathEffect = null;
if (_borderPaint != null)
{
_borderPaint.SetPathEffect(null);
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

After clearing the path effect on the paint, call InvalidateSelf() (or the equivalent) on the drawable to ensure the UI is redrawn immediately.

Suggested change
_borderPaint.SetPathEffect(null);
_borderPaint.SetPathEffect(null);
InvalidateSelf();

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

InvalidateSelf(); is invoked in line 311

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

{
App.WaitForElement("SetDashButton");
App.Tap("SetDashButton");
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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Snapshots available in the latest build.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz , I have added the pending snapshot.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 29910

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 29910"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StrokeDashArray on Border does not reset when set to null StrokeDashArray of a Border control is not well recycled with a CollectionView

3 participants