Skip to content

[iOS/Mac] Fix ImageButton background rendering with oversized CornerRadius - #39487

Open
Dhivya-SF4094 wants to merge 54 commits into
dotnet:mainfrom
Dhivya-SF4094:IssueFix-39485
Open

Dhivya-SF4094 wants to merge 54 commits into
dotnet:mainfrom
Dhivya-SF4094:IssueFix-39485

Conversation

@Dhivya-SF4094

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 Detail

An ImageButton whose CornerRadius is larger than half of its own size does not render at all — the control stays fully transparent (it is still laid out and still receives clicks).

Root cause

On iOS, MAUI passed CornerRadius directly to the native CALayer. When the requested radius exceeded half the button’s size, it was not clamped to the available bounds. The oversized radius could also affect a background layer, leaving the ImageButton visually transparent even though it remained laid out and interactive. The radius was initially mapped before final layout bounds were available.

Description of Change

Clamp the effective radius to half the layer’s smaller dimension, and apply it to both the button layer and its background layer. Reapply the corner-radius mapping after ImageButton layout so the calculation uses final bounds. This restores the expected circular rendering for a 50x50 button with CornerRadius="100" on iOS and Mac Catalyst.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed:

Fixes #39485

Screenshots

Before After

@github-actions

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Oct 20, 2026
@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot added area-controls-button Button, ImageButton platform/ios platform/macos macOS / Mac Catalyst labels Oct 20, 2026
@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 20, 2026
@kubaflo

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.

@kubaflo

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.

@Dhivya-SF4094 Dhivya-SF4094 changed the title [WIP] [iOS/Mac] Fix ImageButton background rendering with oversized CornerRadius [iOS/Mac] Fix ImageButton background rendering with oversized CornerRadius Oct 23, 2026
@kubaflo

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 3 findings · ⚠️ 1 breaking change

Reviewed commit 47ca747.

Warning

Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:

See inline comments for details.

Comment thread src/Core/src/PropertyMapper.cs Resolved
Comment thread src/Core/src/PropertyMapper.cs Resolved
@@ -0,0 +1,266 @@
using System;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[minor] Backward Compatibility and Migration - Record the observable Apple ImageButton mapper contracts in the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton requested at radius 100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later stock CornerRadius mapping claims it again; derived handlers returning an ordinary UIButton retain the old fallback. The design document contains none of these contracts or migration guidance for existing native customizations and derived handlers. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAUI Autopilot · round 15

❌ Not changed. The requested behavior and migration notes belong in docs/design/HandlerResolution.md, which is outside this round’s src/-only scope.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAUI Autopilot · round 16

❌ Not changed. This fix round is limited to src/, so the requested design-document and PR-description updates are out of scope. I’m leaving this open for the author or a maintainer.

github-actions Bot and others added 2 commits November 30, 2026 18:32
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 4 findings · ⚠️ 1 breaking change

Reviewed commit 6c1ee66.

Warning

Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:

See inline comments for details.

1 findings could not be attached inline; retained in run artifacts.

Comment thread src/Core/src/PropertyMapper.cs Resolved
Comment thread src/Core/src/PropertyMapper.cs Resolved
github-actions Bot and others added 3 commits November 30, 2026 19:40
…pper

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…appings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 4 findings · ⚠️ 2 breaking changes

Reviewed commit f1f270d.

Warning

Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:

See inline comments for details.

@@ -1,5 +1,4 @@
using System;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[minor] Backward Compatibility and Migration - Record the observable Apple ImageButton mapper contracts in the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton requested at radius 100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later stock CornerRadius mapping claims it again; derived handlers returning an ordinary UIButton retain the old fallback. The design document contains none of these contracts or migration guidance. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAUI Autopilot · round 17

❌ Not changed. docs/design/HandlerResolution.md and the PR description are outside this source-only fix round, so I’m leaving this open for the maintainer.

github-actions Bot and others added 3 commits November 30, 2026 20:57
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 2 findings

Reviewed commit 1a4bb1b.

See inline comments for details.

@@ -1,5 +1,4 @@
using System;

ghost Nov 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[minor] Backward Compatibility and Migration - The observable Apple ImageButton mapper changes are missing from the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton with CornerRadius=100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later registered CornerRadius mapping claims it again; derived handlers returning an ordinary UIButton retain the old fallback. Document these contracts and migration guidance for existing native customizations and derived handlers, including the distinction between standalone MapCornerRadius calls and registered mappings. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.

ghost Nov 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAUI Autopilot · round 18

❌ Not changed. The requested updates to docs/design/HandlerResolution.md and the PR description are outside this source-only round. I’m leaving this open for the author or a maintainer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 3 findings · ⚠️ 1 breaking change

Reviewed commit 19a6a45.

Warning

Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:

See inline comments for details.

@@ -1,5 +1,4 @@
using System;

ghost Nov 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[minor] Backward Compatibility and Migration - Record the observable Apple ImageButton mapper contracts in the required Behavior changes section of docs/design/HandlerResolution.md. A stock clipped 50x50 ImageButton with CornerRadius=100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, while a later stock registered CornerRadius mapping claims it again; standalone MapCornerRadius calls preserve native-assignment behavior, and derived handlers returning an ordinary UIButton retain the old fallback. The design document contains none of these contracts or migration guidance for existing native customizations and derived handlers. The PR description instead says layout reapplies the mapping, which does not describe the implemented callback behavior.

ghost Nov 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAUI Autopilot · round 19

❌ Not changed. The design document and PR description are outside this round’s src/-only scope. The ViewExtensions.UpdateBackground XML remarks now document the distinction between standalone calls and registered background mappings.

github-actions[bot] and others added 2 commits November 30, 2026 23:31
…updates

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 3 findings

Reviewed commit d38d28e.

See inline comments for details.

Comment thread src/Core/src/PropertyMapper.cs Resolved
@@ -1,5 +1,4 @@
using System;

ghost Dec 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[minor] Backward Compatibility and Migration - Document the changed Apple ImageButton mapper contract in the Behavior changes section of docs/design/HandlerResolution.md, with migration guidance for native customizations and derived handlers. A stock clipped 50x50 ImageButton requested at radius 100 now exposes native radius 25 after mapping, and bounds changes update it without invoking CornerRadius or Padding callbacks. Native radius assignments relinquish automatic ownership, a later registered CornerRadius mapping claims it again, standalone MapCornerRadius calls preserve native-assignment behavior, and custom handlers returning an ordinary UIButton retain the old fallback. These observable rules remain undocumented; the PR description instead says layout reapplies the mapping.

ghost Dec 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAUI Autopilot · round 20

❌ Not changed. The handler-resolution migration guide and PR description are outside this source-only round. The description still needs to say that native bounds observation updates effective radii without rerunning the CornerRadius or Padding mapper.

github-actions[bot] and others added 2 commits December 1, 2026 00:40
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Direct background mapper overrides still receive a prematurely clamped corner radius, causing intended callback customizations to be lost on resize.

2 open issues

Review effort: Balanced

Comment thread src/Core/src/PropertyMapper.cs Resolved
_radiusObservation = KeyValueObservation.ObserveCornerRadius(Layer, OnRadiusChanging, beforeChange: true);
// The System button factory returns a native UIKit button, so managed
// LayoutSubviews overrides cannot be used to observe its geometry.
_boundsObservation = KeyValueObservation.ObserveBounds(Layer, UpdateCornerRadii);

ghost Dec 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

MAUI Autopilot · round 21

❌ Not changed. This fix round cannot edit PR metadata. The implementation uses native bounds observation to update effective radii on resize without rerunning the property mappers.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 5 findings · ⚠️ 3 breaking changes

Reviewed commit 9791a5e.

Warning

Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:

See inline comments for details.

Previously reported findings were not duplicated.

Comment thread src/Core/src/PropertyMapper.cs Resolved
github-actions[bot] and others added 4 commits December 1, 2026 01:48
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The PR description incorrectly says the corner-radius mapper reruns after layout and needs to document native bounds observation, shared mapper dispatch changes, and the KeepMappedGradientRadius compatibility switch.

1 open issue

Review effort: Balanced

@github-actions

This comment has been minimized.

@github-actions

ghost commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Stopped

@kubaflo ❌ The MAUI expert review failed twice in a row. Comment /review autopilot to try again. Run.

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — 34ca9997 Deployed Nov 24, 2026 by kubaflo via conclusion #3288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-button Button, ImageButton 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 s/autopilot-needs-maintainer-decision MAUI Autopilot stopped: a maintainer needs to decide how to continue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS/Mac] ImageButton does not render its background when CornerRadius is larger than half of its size

4 participants