Skip to content

[iOS/Mac] Fix Button with gradient Background ignores CornerRadius - #39484

Merged
kubaflo merged 2 commits into
dotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-39450
Oct 21, 2026
Merged

kubaflo merged 2 commits into
dotnet:inflight/currentfrom
HarishwaranVijayakumar:fix-39450

Conversation

@HarishwaranVijayakumar

Copy link
Copy Markdown
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!

Issue Details

  • On iOS and Mac Catalyst, a Button with a gradient background and a non-zero CornerRadius displays a rounded border, but the gradient background extends beyond the rounded corners.
  • Solid-color backgrounds are not affected.

Root Cause

  • PR [Android, iOS] Button: Fix VisualState properties not restored when leaving custom state #33346 introduced a new button-specific background update path to correctly clear backgrounds during VisualState changes.
  • During this change, the button's stroke information (including CornerRadius) was no longer passed through the background rendering flow.
  • As a result, gradient background layers no longer received the CornerRadius value, causing the gradient to render with square corners while the native button itself remained rounded.

Description of Change

Button background rendering improvements:

  • Updated the UpdateBackground extension method in ButtonExtensions.cs to accept an optional IButtonStroke parameter, allowing the background rendering logic to respect the button's CornerRadius. The method now passes this parameter to the underlying view background update logic.
  • Modified the MapBackground method in ButtonHandler.iOS.cs to pass the button instance as the stroke parameter when updating the background, ensuring the platform view can access the CornerRadius property.

Test coverage:

  • Added a new test page (Issue39450.cs) to verify that various button backgrounds—linear gradient, radial gradient, and visual state-driven backgrounds—are clipped to the rounded corners as expected.
  • Introduced a corresponding UI test (Issue39450.cs in TestCases.Shared.Tests) that toggles button visual states and checks via screenshots and label assertions that the background remains within the rounded borders.

Issues Fixed

Fixes #39450

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Output

Before After

@github-actions

Copy link
Copy Markdown
Contributor

🚀 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 -- 39484

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Oct 20, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@vishnumenon2684

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@HarishwaranVijayakumar HarishwaranVijayakumar changed the title [WIP] [iOS/Mac] Fix Button with gradient Background ignores CornerRadius [iOS/Mac] Fix Button with gradient Background ignores CornerRadius Oct 21, 2026
@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Oct 21, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@HarishwaranVijayakumar — test-failure analysis for commit a8e644c.

Scope CI failures Commit a8e644c


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests
  • 🟢 Likely unrelated — Android ImageWithUndefinedSizeAndWithBackgroundSetRenders: identical missing-red assertion on main; Android rendering is unchanged.
  • 🟡 Needs human investigation — Android Mono work-item crash: crash signal leaves coverage incomplete; inspect the console's terminating exception.
  • 🟡 Needs human investigation — MacCatalyst Mono Core Tests: 3600-second timeout without test outcomes; target history lacks matching diagnostics. Capture the hang location. Both failed PowerShell tasks report these work-item failures, not compilation errors.

🧪 maui-pr-uitests

🧭 Follow-up — actions and refresh

Next action: Compare unresolved Mac cases with/without the Button change under identical setup; collect hang/crash diagnostics and missing Shell2 outcomes.

Maintainers: comment /review tests to refresh this report.

This was referenced Nov 16, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-button Button, ImageButton community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst s/agent-review-in-progress AI review is currently running for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Button with gradient Background ignores CornerRadius (regression in 10.0.80)

4 participants