Skip to content

[iOS/Mac] Keep Button caption visible when its Text changes - #40348

Merged
kubaflo merged 1 commit into
candidate/11.0.1xx-sr2from
fix-mac-button-caption
Nov 17, 2026
Merged

kubaflo merged 1 commit into
candidate/11.0.1xx-sr2from
fix-mac-button-caption

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 17, 2026

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!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

This targets candidate/11.0.1xx-sr2, the branch explicitly designated for fixes to failures found on the SR2 candidate PR #40116. A maintainer decides any retargeting and the merge.

Description of Change

Symptom. Issue25074.ButtonResizesWhenTitleOrImageChanges fails on Mac Catalyst in candidate UI runs and also on net11:

  • candidate UI 1685512, run 47045068, result 100228: Altered.png differs by 1.14% on both the first attempt and the retry.
  • net11 UI 1685487, run 47044278, result 100223.
  • The captured screenshots show buttons with no caption: the caption pixels are just the button background.

Root cause. The handler creates a UIButtonType.System button. When SetTitle changes the title, UIKit cross-fades it:

  • the TitleLabel alpha is set to 0 immediately and an opacity animation is added;
  • only that animation's completion sets the alpha back to 1.

So if the completion does not run, the caption stays invisible.

Fix. Controls ButtonExtensions.UpdateText (iOS/Mac Catalyst) now applies SetTitle and the existing TitleLabel.Text assignment inside UIView.PerformWithoutAnimation, so the label is never faded out. StepperExtensions already uses the same pattern. UpdateCharacterSpacing/SetAttributedTitle still runs afterwards, unchanged, and the tracing showed it does not fade.

Not changed. Core src/Core/src/Platform/iOS/ButtonExtensions.cs UpdateText is left as is. It is only used by non-Controls IButton implementations, because Controls Button maps Text through the Controls extension.

Test. New iOS/Mac Catalyst device test ButtonTests.TextChangeKeepsTitleLabelVisible. It adds a Button to a window, changes its Text, then asserts that TitleLabel.Alpha == 1 and that the label has no opacity animation. All existing assertions and oracles are unchanged; no screenshot baselines, tolerances or masks were touched.

Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5 buttons × 40 iterations = 200 samples.

Run Product code Faded captions (alpha 0)
Baseline unchanged 200/200
Fix PerformWithoutAnimation 0/200
Fix reverted unchanged 200/200
Fix restored PerformWithoutAnimation 0/200

iOS device tests on the iOS 26.0 simulator, using xharness apple test with TestFilter=Category=Button:

Run Result
With the fix 23/23 passed, including TextChangeKeepsTitleLabelVisible
Fix reverted (test kept) 22/23 passed; TextChangeKeepsTitleLabelVisible fails with Expected: 1, Actual: 0 (alpha)
Fix restored 23/23 passed

The existing TextUpdatesAttributedTitleWhenCharacterSpacingApplied test (#40189) passes in all three runs.

dotnet format whitespace --folder --verify-no-changes on both changed files reports no changes.

Limitations

  • Local validation used Xcode 27.2; the repo pins Xcode 27.0.
  • The fix removes the alpha-0 state that matches the CI screenshots in every sample. Why the fade's completion does not run in CI is not proven.
  • This PR does not claim any other Mac visual failure is fixed. The UI test will be confirmed by this PR's own CI.

Issues Fixed

Fixes the Issue25074.ButtonResizesWhenTitleOrImageChanges Mac Catalyst failure observed on #40116. No separate issue was filed.

A UIButtonType.System button cross-fades its title on SetTitle: the
TitleLabel's alpha is set to 0 synchronously and only the fade
animation's completion restores it. When that completion does not run,
the caption stays invisible (Issue25074 ButtonResizesWhenTitleOrImageChanges
on Mac Catalyst shows buttons with no captions).

Apply the title update inside UIView.PerformWithoutAnimation so the label
is never faded out, and add a device test asserting the TitleLabel keeps
alpha 1 with no opacity animation after a Text change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 17, 2026 22:09 — with GitHub Actions Inactive
@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 17, 2026 22:09 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 17, 2026 22:11 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 17, 2026 22:13 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 17, 2026 22:14 — with GitHub Actions Inactive
@github-actions github-actions Bot added area-controls-button Button, ImageButton platform/ios platform/macos macOS / Mac Catalyst labels Nov 17, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 17, 2026 22:15 — with GitHub Actions Inactive
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 17, 2026
@kubaflo

kubaflo commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform iOS


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 17, 2026

@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 — 0 findings

Reviewed commit 1dcc53c.

@kubaflo
kubaflo merged commit f14ddfd into candidate/11.0.1xx-sr2 Nov 17, 2026
35 of 68 checks passed
@kubaflo
kubaflo deleted the fix-mac-button-caption branch November 17, 2026 23:54
@kubaflo

kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up evidence: this change also covers Issue30066(Mac).DatePickerCharacterSpacingCanChange.

  • Candidate UI build 1686311 at 9aabb914f1 (before this PR merged): run 47069432, result 100057, DatePickerCharacterSpacingCanChange.png 0.72% difference. It also failed both attempts in PR Fix IndicatorTemplate in IndicatorView does not update when set dynamically without initial value #40133's UI build 1685442.
  • The failure screenshot differs from the checked-in baseline only by the missing ChangeSpacingButton caption. The page source still reports the label Change Character Spacing to 10. The test's tap changes button.Text, which triggers the same UIButtonType.System title cross-fade this PR suppresses.

Local Mac Catalyst probe: TestCases.HostApp at 9aabb914f1, issue page opened directly, ChangeSpacingButton tapped 40 times. Each cell is the number of samples where TitleLabel.Alpha == 0 / an opacity animation is still attached, out of 40.

Build 50 ms 300 ms 1500 ms
Baseline (no fix) 40 / 40 0 / 40 0 / 0
This fix 0 / 0 0 / 0 0 / 0
Fix reverted 40 / 40 0 / 40 0 / 0
Fix restored 0 / 0 0 / 0 0 / 0

Limitations: the probe measures the UIKit caption state that the screenshot captured, not a CI rerun of the UI test. Other Mac visual failures with a missing caption (VSM Entry, Shell2 ClearPlaceholder, Issue31899) show the same symptom but were not probed here.

@kubaflo kubaflo mentioned this pull request Nov 18, 2026
1 task
kubaflo added a commit that referenced this pull request Nov 18, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This targets `candidate/11.0.1xx-sr2`, the branch explicitly designated
for fixes to failures found on the SR2 candidate PR #40116. A maintainer
decides any retargeting and the merge.

### Description of Change

**Symptom.** `Issue25074.ButtonResizesWhenTitleOrImageChanges` fails on
Mac Catalyst in candidate UI runs and also on `net11`:
- candidate UI 1685512, run 47045068, result 100228: `Altered.png`
differs by 1.14% on both the first attempt and the retry.
- net11 UI 1685487, run 47044278, result 100223.
- The captured screenshots show buttons with **no caption**: the caption
pixels are just the button background.

**Root cause.** The handler creates a `UIButtonType.System` button. When
`SetTitle` changes the title, UIKit cross-fades it:
- the `TitleLabel` alpha is set to `0` immediately and an `opacity`
animation is added;
- only that animation's completion sets the alpha back to `1`.

So if the completion does not run, the caption stays invisible.

**Fix.** Controls `ButtonExtensions.UpdateText` (iOS/Mac Catalyst) now
applies `SetTitle` and the existing `TitleLabel.Text` assignment inside
`UIView.PerformWithoutAnimation`, so the label is never faded out.
`StepperExtensions` already uses the same pattern.
`UpdateCharacterSpacing`/`SetAttributedTitle` still runs afterwards,
unchanged, and the tracing showed it does not fade.

**Not changed.** Core `src/Core/src/Platform/iOS/ButtonExtensions.cs`
`UpdateText` is left as is. It is only used by non-Controls `IButton`
implementations, because Controls `Button` maps Text through the
Controls extension.

**Test.** New iOS/Mac Catalyst device test
`ButtonTests.TextChangeKeepsTitleLabelVisible`. It adds a Button to a
window, changes its `Text`, then asserts that `TitleLabel.Alpha == 1`
and that the label has no `opacity` animation. All existing assertions
and oracles are unchanged; no screenshot baselines, tolerances or masks
were touched.

### Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run
samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5
buttons × 40 iterations = 200 samples.

| Run | Product code | Faded captions (alpha 0) |
| --- | --- | --- |
| Baseline | unchanged | **200/200** |
| Fix | `PerformWithoutAnimation` | **0/200** |
| Fix reverted | unchanged | **200/200** |
| Fix restored | `PerformWithoutAnimation` | **0/200** |

iOS device tests on the iOS 26.0 simulator, using `xharness apple test`
with `TestFilter=Category=Button`:

| Run | Result |
| --- | --- |
| With the fix | 23/23 passed, including
`TextChangeKeepsTitleLabelVisible` |
| Fix reverted (test kept) | 22/23 passed;
`TextChangeKeepsTitleLabelVisible` fails with `Expected: 1, Actual: 0`
(alpha) |
| Fix restored | 23/23 passed |

The existing `TextUpdatesAttributedTitleWhenCharacterSpacingApplied`
test (#40189) passes in all three runs.

`dotnet format whitespace --folder --verify-no-changes` on both changed
files reports no changes.

**Limitations**
- Local validation used Xcode 27.2; the repo pins Xcode 27.0.
- The fix removes the alpha-0 state that matches the CI screenshots in
every sample. Why the fade's completion does not run in CI is not
proven.
- This PR does not claim any other Mac visual failure is fixed. The UI
test will be confirmed by this PR's own CI.

### Issues Fixed

Fixes the `Issue25074.ButtonResizesWhenTitleOrImageChanges` Mac Catalyst
failure observed on #40116. No separate issue was filed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This targets `candidate/11.0.1xx-sr2`, the branch explicitly designated
for fixes to failures found on the SR2 candidate PR #40116. A maintainer
decides any retargeting and the merge.

### Description of Change

**Symptom.** `Issue25074.ButtonResizesWhenTitleOrImageChanges` fails on
Mac Catalyst in candidate UI runs and also on `net11`:
- candidate UI 1685512, run 47045068, result 100228: `Altered.png`
differs by 1.14% on both the first attempt and the retry.
- net11 UI 1685487, run 47044278, result 100223.
- The captured screenshots show buttons with **no caption**: the caption
pixels are just the button background.

**Root cause.** The handler creates a `UIButtonType.System` button. When
`SetTitle` changes the title, UIKit cross-fades it:
- the `TitleLabel` alpha is set to `0` immediately and an `opacity`
animation is added;
- only that animation's completion sets the alpha back to `1`.

So if the completion does not run, the caption stays invisible.

**Fix.** Controls `ButtonExtensions.UpdateText` (iOS/Mac Catalyst) now
applies `SetTitle` and the existing `TitleLabel.Text` assignment inside
`UIView.PerformWithoutAnimation`, so the label is never faded out.
`StepperExtensions` already uses the same pattern.
`UpdateCharacterSpacing`/`SetAttributedTitle` still runs afterwards,
unchanged, and the tracing showed it does not fade.

**Not changed.** Core `src/Core/src/Platform/iOS/ButtonExtensions.cs`
`UpdateText` is left as is. It is only used by non-Controls `IButton`
implementations, because Controls `Button` maps Text through the
Controls extension.

**Test.** New iOS/Mac Catalyst device test
`ButtonTests.TextChangeKeepsTitleLabelVisible`. It adds a Button to a
window, changes its `Text`, then asserts that `TitleLabel.Alpha == 1`
and that the label has no `opacity` animation. All existing assertions
and oracles are unchanged; no screenshot baselines, tolerances or masks
were touched.

### Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run
samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5
buttons × 40 iterations = 200 samples.

| Run | Product code | Faded captions (alpha 0) |
| --- | --- | --- |
| Baseline | unchanged | **200/200** |
| Fix | `PerformWithoutAnimation` | **0/200** |
| Fix reverted | unchanged | **200/200** |
| Fix restored | `PerformWithoutAnimation` | **0/200** |

iOS device tests on the iOS 26.0 simulator, using `xharness apple test`
with `TestFilter=Category=Button`:

| Run | Result |
| --- | --- |
| With the fix | 23/23 passed, including
`TextChangeKeepsTitleLabelVisible` |
| Fix reverted (test kept) | 22/23 passed;
`TextChangeKeepsTitleLabelVisible` fails with `Expected: 1, Actual: 0`
(alpha) |
| Fix restored | 23/23 passed |

The existing `TextUpdatesAttributedTitleWhenCharacterSpacingApplied`
test (#40189) passes in all three runs.

`dotnet format whitespace --folder --verify-no-changes` on both changed
files reports no changes.

**Limitations**
- Local validation used Xcode 27.2; the repo pins Xcode 27.0.
- The fix removes the alpha-0 state that matches the CI screenshots in
every sample. Why the fade's completion does not run in CI is not
proven.
- This PR does not claim any other Mac visual failure is fixed. The UI
test will be confirmed by this PR's own CI.

### Issues Fixed

Fixes the `Issue25074.ButtonResizesWhenTitleOrImageChanges` Mac Catalyst
failure observed on #40116. No separate issue was filed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This targets `candidate/11.0.1xx-sr2`, the branch explicitly designated
for fixes to failures found on the SR2 candidate PR #40116. A maintainer
decides any retargeting and the merge.

### Description of Change

**Symptom.** `Issue25074.ButtonResizesWhenTitleOrImageChanges` fails on
Mac Catalyst in candidate UI runs and also on `net11`:
- candidate UI 1685512, run 47045068, result 100228: `Altered.png`
differs by 1.14% on both the first attempt and the retry.
- net11 UI 1685487, run 47044278, result 100223.
- The captured screenshots show buttons with **no caption**: the caption
pixels are just the button background.

**Root cause.** The handler creates a `UIButtonType.System` button. When
`SetTitle` changes the title, UIKit cross-fades it:
- the `TitleLabel` alpha is set to `0` immediately and an `opacity`
animation is added;
- only that animation's completion sets the alpha back to `1`.

So if the completion does not run, the caption stays invisible.

**Fix.** Controls `ButtonExtensions.UpdateText` (iOS/Mac Catalyst) now
applies `SetTitle` and the existing `TitleLabel.Text` assignment inside
`UIView.PerformWithoutAnimation`, so the label is never faded out.
`StepperExtensions` already uses the same pattern.
`UpdateCharacterSpacing`/`SetAttributedTitle` still runs afterwards,
unchanged, and the tracing showed it does not fade.

**Not changed.** Core `src/Core/src/Platform/iOS/ButtonExtensions.cs`
`UpdateText` is left as is. It is only used by non-Controls `IButton`
implementations, because Controls `Button` maps Text through the
Controls extension.

**Test.** New iOS/Mac Catalyst device test
`ButtonTests.TextChangeKeepsTitleLabelVisible`. It adds a Button to a
window, changes its `Text`, then asserts that `TitleLabel.Alpha == 1`
and that the label has no `opacity` animation. All existing assertions
and oracles are unchanged; no screenshot baselines, tolerances or masks
were touched.

### Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run
samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5
buttons × 40 iterations = 200 samples.

| Run | Product code | Faded captions (alpha 0) |
| --- | --- | --- |
| Baseline | unchanged | **200/200** |
| Fix | `PerformWithoutAnimation` | **0/200** |
| Fix reverted | unchanged | **200/200** |
| Fix restored | `PerformWithoutAnimation` | **0/200** |

iOS device tests on the iOS 26.0 simulator, using `xharness apple test`
with `TestFilter=Category=Button`:

| Run | Result |
| --- | --- |
| With the fix | 23/23 passed, including
`TextChangeKeepsTitleLabelVisible` |
| Fix reverted (test kept) | 22/23 passed;
`TextChangeKeepsTitleLabelVisible` fails with `Expected: 1, Actual: 0`
(alpha) |
| Fix restored | 23/23 passed |

The existing `TextUpdatesAttributedTitleWhenCharacterSpacingApplied`
test (#40189) passes in all three runs.

`dotnet format whitespace --folder --verify-no-changes` on both changed
files reports no changes.

**Limitations**
- Local validation used Xcode 27.2; the repo pins Xcode 27.0.
- The fix removes the alpha-0 state that matches the CI screenshots in
every sample. Why the fade's completion does not run in CI is not
proven.
- This PR does not claim any other Mac visual failure is fixed. The UI
test will be confirmed by this PR's own CI.

### Issues Fixed

Fixes the `Issue25074.ButtonResizesWhenTitleOrImageChanges` Mac Catalyst
failure observed on #40116. No separate issue was filed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This targets `candidate/11.0.1xx-sr2`, the branch explicitly designated
for fixes to failures found on the SR2 candidate PR #40116. A maintainer
decides any retargeting and the merge.

### Description of Change

**Symptom.** `Issue25074.ButtonResizesWhenTitleOrImageChanges` fails on
Mac Catalyst in candidate UI runs and also on `net11`:
- candidate UI 1685512, run 47045068, result 100228: `Altered.png`
differs by 1.14% on both the first attempt and the retry.
- net11 UI 1685487, run 47044278, result 100223.
- The captured screenshots show buttons with **no caption**: the caption
pixels are just the button background.

**Root cause.** The handler creates a `UIButtonType.System` button. When
`SetTitle` changes the title, UIKit cross-fades it:
- the `TitleLabel` alpha is set to `0` immediately and an `opacity`
animation is added;
- only that animation's completion sets the alpha back to `1`.

So if the completion does not run, the caption stays invisible.

**Fix.** Controls `ButtonExtensions.UpdateText` (iOS/Mac Catalyst) now
applies `SetTitle` and the existing `TitleLabel.Text` assignment inside
`UIView.PerformWithoutAnimation`, so the label is never faded out.
`StepperExtensions` already uses the same pattern.
`UpdateCharacterSpacing`/`SetAttributedTitle` still runs afterwards,
unchanged, and the tracing showed it does not fade.

**Not changed.** Core `src/Core/src/Platform/iOS/ButtonExtensions.cs`
`UpdateText` is left as is. It is only used by non-Controls `IButton`
implementations, because Controls `Button` maps Text through the
Controls extension.

**Test.** New iOS/Mac Catalyst device test
`ButtonTests.TextChangeKeepsTitleLabelVisible`. It adds a Button to a
window, changes its `Text`, then asserts that `TitleLabel.Alpha == 1`
and that the label has no `opacity` animation. All existing assertions
and oracles are unchanged; no screenshot baselines, tolerances or masks
were touched.

### Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run
samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5
buttons × 40 iterations = 200 samples.

| Run | Product code | Faded captions (alpha 0) |
| --- | --- | --- |
| Baseline | unchanged | **200/200** |
| Fix | `PerformWithoutAnimation` | **0/200** |
| Fix reverted | unchanged | **200/200** |
| Fix restored | `PerformWithoutAnimation` | **0/200** |

iOS device tests on the iOS 26.0 simulator, using `xharness apple test`
with `TestFilter=Category=Button`:

| Run | Result |
| --- | --- |
| With the fix | 23/23 passed, including
`TextChangeKeepsTitleLabelVisible` |
| Fix reverted (test kept) | 22/23 passed;
`TextChangeKeepsTitleLabelVisible` fails with `Expected: 1, Actual: 0`
(alpha) |
| Fix restored | 23/23 passed |

The existing `TextUpdatesAttributedTitleWhenCharacterSpacingApplied`
test (#40189) passes in all three runs.

`dotnet format whitespace --folder --verify-no-changes` on both changed
files reports no changes.

**Limitations**
- Local validation used Xcode 27.2; the repo pins Xcode 27.0.
- The fix removes the alpha-0 state that matches the CI screenshots in
every sample. Why the fade's completion does not run in CI is not
proven.
- This PR does not claim any other Mac visual failure is fixed. The UI
test will be confirmed by this PR's own CI.

### Issues Fixed

Fixes the `Issue25074.ButtonResizesWhenTitleOrImageChanges` Mac Catalyst
failure observed on #40116. No separate issue was filed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This targets `candidate/11.0.1xx-sr2`, the branch explicitly designated
for fixes to failures found on the SR2 candidate PR #40116. A maintainer
decides any retargeting and the merge.

### Description of Change

**Symptom.** `Issue25074.ButtonResizesWhenTitleOrImageChanges` fails on
Mac Catalyst in candidate UI runs and also on `net11`:
- candidate UI 1685512, run 47045068, result 100228: `Altered.png`
differs by 1.14% on both the first attempt and the retry.
- net11 UI 1685487, run 47044278, result 100223.
- The captured screenshots show buttons with **no caption**: the caption
pixels are just the button background.

**Root cause.** The handler creates a `UIButtonType.System` button. When
`SetTitle` changes the title, UIKit cross-fades it:
- the `TitleLabel` alpha is set to `0` immediately and an `opacity`
animation is added;
- only that animation's completion sets the alpha back to `1`.

So if the completion does not run, the caption stays invisible.

**Fix.** Controls `ButtonExtensions.UpdateText` (iOS/Mac Catalyst) now
applies `SetTitle` and the existing `TitleLabel.Text` assignment inside
`UIView.PerformWithoutAnimation`, so the label is never faded out.
`StepperExtensions` already uses the same pattern.
`UpdateCharacterSpacing`/`SetAttributedTitle` still runs afterwards,
unchanged, and the tracing showed it does not fade.

**Not changed.** Core `src/Core/src/Platform/iOS/ButtonExtensions.cs`
`UpdateText` is left as is. It is only used by non-Controls `IButton`
implementations, because Controls `Button` maps Text through the
Controls extension.

**Test.** New iOS/Mac Catalyst device test
`ButtonTests.TextChangeKeepsTitleLabelVisible`. It adds a Button to a
window, changes its `Text`, then asserts that `TitleLabel.Alpha == 1`
and that the label has no `opacity` animation. All existing assertions
and oracles are unchanged; no screenshot baselines, tolerances or masks
were touched.

### Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run
samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5
buttons × 40 iterations = 200 samples.

| Run | Product code | Faded captions (alpha 0) |
| --- | --- | --- |
| Baseline | unchanged | **200/200** |
| Fix | `PerformWithoutAnimation` | **0/200** |
| Fix reverted | unchanged | **200/200** |
| Fix restored | `PerformWithoutAnimation` | **0/200** |

iOS device tests on the iOS 26.0 simulator, using `xharness apple test`
with `TestFilter=Category=Button`:

| Run | Result |
| --- | --- |
| With the fix | 23/23 passed, including
`TextChangeKeepsTitleLabelVisible` |
| Fix reverted (test kept) | 22/23 passed;
`TextChangeKeepsTitleLabelVisible` fails with `Expected: 1, Actual: 0`
(alpha) |
| Fix restored | 23/23 passed |

The existing `TextUpdatesAttributedTitleWhenCharacterSpacingApplied`
test (#40189) passes in all three runs.

`dotnet format whitespace --folder --verify-no-changes` on both changed
files reports no changes.

**Limitations**
- Local validation used Xcode 27.2; the repo pins Xcode 27.0.
- The fix removes the alpha-0 state that matches the CI screenshots in
every sample. Why the fade's completion does not run in CI is not
proven.
- This PR does not claim any other Mac visual failure is fixed. The UI
test will be confirmed by this PR's own CI.

### Issues Fixed

Fixes the `Issue25074.ButtonResizesWhenTitleOrImageChanges` Mac Catalyst
failure observed on #40116. No separate issue was filed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This targets `candidate/11.0.1xx-sr2`, the branch explicitly designated
for fixes to failures found on the SR2 candidate PR #40116. A maintainer
decides any retargeting and the merge.

### Description of Change

**Symptom.** `Issue25074.ButtonResizesWhenTitleOrImageChanges` fails on
Mac Catalyst in candidate UI runs and also on `net11`:
- candidate UI 1685512, run 47045068, result 100228: `Altered.png`
differs by 1.14% on both the first attempt and the retry.
- net11 UI 1685487, run 47044278, result 100223.
- The captured screenshots show buttons with **no caption**: the caption
pixels are just the button background.

**Root cause.** The handler creates a `UIButtonType.System` button. When
`SetTitle` changes the title, UIKit cross-fades it:
- the `TitleLabel` alpha is set to `0` immediately and an `opacity`
animation is added;
- only that animation's completion sets the alpha back to `1`.

So if the completion does not run, the caption stays invisible.

**Fix.** Controls `ButtonExtensions.UpdateText` (iOS/Mac Catalyst) now
applies `SetTitle` and the existing `TitleLabel.Text` assignment inside
`UIView.PerformWithoutAnimation`, so the label is never faded out.
`StepperExtensions` already uses the same pattern.
`UpdateCharacterSpacing`/`SetAttributedTitle` still runs afterwards,
unchanged, and the tracing showed it does not fade.

**Not changed.** Core `src/Core/src/Platform/iOS/ButtonExtensions.cs`
`UpdateText` is left as is. It is only used by non-Controls `IButton`
implementations, because Controls `Button` maps Text through the
Controls extension.

**Test.** New iOS/Mac Catalyst device test
`ButtonTests.TextChangeKeepsTitleLabelVisible`. It adds a Button to a
window, changes its `Text`, then asserts that `TitleLabel.Alpha == 1`
and that the label has no `opacity` animation. All existing assertions
and oracles are unchanged; no screenshot baselines, tolerances or masks
were touched.

### Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run
samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5
buttons × 40 iterations = 200 samples.

| Run | Product code | Faded captions (alpha 0) |
| --- | --- | --- |
| Baseline | unchanged | **200/200** |
| Fix | `PerformWithoutAnimation` | **0/200** |
| Fix reverted | unchanged | **200/200** |
| Fix restored | `PerformWithoutAnimation` | **0/200** |

iOS device tests on the iOS 26.0 simulator, using `xharness apple test`
with `TestFilter=Category=Button`:

| Run | Result |
| --- | --- |
| With the fix | 23/23 passed, including
`TextChangeKeepsTitleLabelVisible` |
| Fix reverted (test kept) | 22/23 passed;
`TextChangeKeepsTitleLabelVisible` fails with `Expected: 1, Actual: 0`
(alpha) |
| Fix restored | 23/23 passed |

The existing `TextUpdatesAttributedTitleWhenCharacterSpacingApplied`
test (#40189) passes in all three runs.

`dotnet format whitespace --folder --verify-no-changes` on both changed
files reports no changes.

**Limitations**
- Local validation used Xcode 27.2; the repo pins Xcode 27.0.
- The fix removes the alpha-0 state that matches the CI screenshots in
every sample. Why the fade's completion does not run in CI is not
proven.
- This PR does not claim any other Mac visual failure is fixed. The UI
test will be confirmed by this PR's own CI.

### Issues Fixed

Fixes the `Issue25074.ButtonResizesWhenTitleOrImageChanges` Mac Catalyst
failure observed on #40116. No separate issue was filed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…0348)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This targets `candidate/11.0.1xx-sr2`, the branch explicitly designated
for fixes to failures found on the SR2 candidate PR dotnet#40116. A maintainer
decides any retargeting and the merge.

### Description of Change

**Symptom.** `Issue25074.ButtonResizesWhenTitleOrImageChanges` fails on
Mac Catalyst in candidate UI runs and also on `net11`:
- candidate UI 1685512, run 47045068, result 100228: `Altered.png`
differs by 1.14% on both the first attempt and the retry.
- net11 UI 1685487, run 47044278, result 100223.
- The captured screenshots show buttons with **no caption**: the caption
pixels are just the button background.

**Root cause.** The handler creates a `UIButtonType.System` button. When
`SetTitle` changes the title, UIKit cross-fades it:
- the `TitleLabel` alpha is set to `0` immediately and an `opacity`
animation is added;
- only that animation's completion sets the alpha back to `1`.

So if the completion does not run, the caption stays invisible.

**Fix.** Controls `ButtonExtensions.UpdateText` (iOS/Mac Catalyst) now
applies `SetTitle` and the existing `TitleLabel.Text` assignment inside
`UIView.PerformWithoutAnimation`, so the label is never faded out.
`StepperExtensions` already uses the same pattern.
`UpdateCharacterSpacing`/`SetAttributedTitle` still runs afterwards,
unchanged, and the tracing showed it does not fade.

**Not changed.** Core `src/Core/src/Platform/iOS/ButtonExtensions.cs`
`UpdateText` is left as is. It is only used by non-Controls `IButton`
implementations, because Controls `Button` maps Text through the
Controls extension.

**Test.** New iOS/Mac Catalyst device test
`ButtonTests.TextChangeKeepsTitleLabelVisible`. It adds a Button to a
window, changes its `Text`, then asserts that `TitleLabel.Alpha == 1`
and that the label has no `opacity` animation. All existing assertions
and oracles are unchanged; no screenshot baselines, tolerances or masks
were touched.

### Validation

Mac Catalyst HostApp, Issue25074 page, 40 iterations per run. Each run
samples the caption labels of B1–B4 and B9 at 50 ms after the change: 5
buttons × 40 iterations = 200 samples.

| Run | Product code | Faded captions (alpha 0) |
| --- | --- | --- |
| Baseline | unchanged | **200/200** |
| Fix | `PerformWithoutAnimation` | **0/200** |
| Fix reverted | unchanged | **200/200** |
| Fix restored | `PerformWithoutAnimation` | **0/200** |

iOS device tests on the iOS 26.0 simulator, using `xharness apple test`
with `TestFilter=Category=Button`:

| Run | Result |
| --- | --- |
| With the fix | 23/23 passed, including
`TextChangeKeepsTitleLabelVisible` |
| Fix reverted (test kept) | 22/23 passed;
`TextChangeKeepsTitleLabelVisible` fails with `Expected: 1, Actual: 0`
(alpha) |
| Fix restored | 23/23 passed |

The existing `TextUpdatesAttributedTitleWhenCharacterSpacingApplied`
test (dotnet#40189) passes in all three runs.

`dotnet format whitespace --folder --verify-no-changes` on both changed
files reports no changes.

**Limitations**
- Local validation used Xcode 27.2; the repo pins Xcode 27.0.
- The fix removes the alpha-0 state that matches the CI screenshots in
every sample. Why the fade's completion does not run in CI is not
proven.
- This PR does not claim any other Mac visual failure is fixed. The UI
test will be confirmed by this PR's own CI.

### Issues Fixed

Fixes the `Issue25074.ButtonResizesWhenTitleOrImageChanges` Mac Catalyst
failure observed on dotnet#40116. No separate issue was filed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…stay clipped (dotnet#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR dotnet#40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (dotnet#40346,
dotnet#40348, dotnet#40349, dotnet#40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. dotnet#40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before dotnet#40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since dotnet#40175 (and dotnet#40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to dotnet#570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (dotnet#40116).

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

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 1dcc53c9 Deployed Nov 17, 2026 by kubaflo via conclusion #3053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-button Button, ImageButton platform/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants