[iOS] Button RTL text and image overlap - fix#29041
[iOS] Button RTL text and image overlap - fix#29041kubaflo merged 10 commits intodotnet:inflight/currentfrom
Conversation
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…#34317) <!-- 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! ### Description of Change Add `darc-*` to the `trigger: branches: include:` section in `ci-uitests.yml` and `ci-device-tests.yml` so that `maui-pr-uitests` and `maui-pr-devicetests` automatically run when dotnet-maestro pushes dependency updates to `darc-*` branches. Previously, these pipelines required manual `/azp run` comments on every maestro PR. ### Issues Fixed N/A - CI improvement ### Files Changed - `eng/pipelines/ci-uitests.yml` - Added `darc-*` to CI trigger branch filter - `eng/pipelines/ci-device-tests.yml` - Added `darc-*` to CI trigger branch filter Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…otnet#34327) <!-- 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! ## Description PR dotnet#34320 fixed RS0017 analyzer errors caused by `#nullable enable` being sorted to the bottom of 14 Maps `PublicAPI.Unshipped.txt` files. The root cause was a prior Copilot agent session that used `LC_ALL=C sort -u` to resolve merge conflicts — the BOM bytes (`0xEF 0xBB 0xBF`) sort after all ASCII characters, pushing the directive below the API entries. This updates the Copilot instructions to prevent this from recurring: - Explains that `#nullable enable` must remain on line 1 - Warns against using plain `sort` on these files (BOM sort ordering) - Provides a safe conflict resolution script that preserves the header before sorting API entries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…otnet#34301) ### Description of Change Fixes a crash on Android when using `TapGestureRecognizer` with `GraphicsView`. ### Root Cause `PlatformTouchGraphicsView.TouchesMoved` assumed that `_lastMovedViewPoints` always contained at least one element. In certain touch event sequences (triggered when a TapGestureRecognizer is attached), `_lastMovedViewPoints` could be empty while `points.Length == 1`, leading to an IndexOutOfRangeException. ### Fix Added a length check before accessing `_lastMovedViewPoints[0]` to prevent out-of-range access. ### Verified Scenarios - TapGestureRecognizer no longer causes a crash - Tap events fire correctly - Drag interaction remains functional - Multitouch does not crash Fixes dotnet#34296
…lView (dotnet#34279) > [!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! ### Root Cause PR dotnet#33281 added a `GetDesiredSize()` override in `LabelHandler.Android.cs` to fix issue dotnet#31782 (WordWrap labels reporting full constraint width instead of actual text width). The fix computes the longest wrapped line and returns that as the desired width. This causes a regression when `MaxLines` is set on the label: 1. `GetDesiredSize()` is called at the full available width — text wraps cleanly within MaxLines limit 2. The fix returns the shorter "longest line" width 3. The label is arranged at that narrower width 4. At the narrower width, the same text needs more lines — exceeding MaxLines → text is clipped ### Description of Change The `GetDesiredSize()` override now uses a double-measurement strategy: 1. **Entry guard**: Only applies the width-narrowing when `Ellipsize == null` (no active truncation). 2. **Compute candidate width**: Finds the widest rendered line as before. 3. **Safety check** (only when `MaxLines` is explicitly set): Re-measures the TextView at exactly the narrowed pixel width. If the re-measurement shows the text would now exceed `MaxLines`, the original full width is returned instead. 4. **Narrow when safe**: If the re-measurement confirms the same or fewer lines, the narrowed width is returned — preserving the dotnet#31782 alignment fix even for labels with explicit `MaxLines`. This avoids both regressions: - Labels without `MaxLines` behave as before (alignment fix preserved, no second measure). - Labels with `MaxLines` that have line-count headroom also get the alignment fix. ### Issues Fixed Fixes dotnet#34120 ### Tested platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac **Files Changed in this PR:** | File | Change | |------|--------| | `src/Core/src/Handlers/Label/LabelHandler.Android.cs` | Double-measurement fix (~20 lines) | | `src/Controls/tests/TestCases.HostApp/Issues/Issue34120.cs` | New UI test HostApp page | | `src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34120.cs` | New NUnit UI test | **Regression Reference:** - Regressed by: PR dotnet#33281 - Introduced in: 10.0.40 - Works in: 10.0.30, 10.0.31 - Platform: Android only ### Screenshots |Before|After| |--|--| |<img width="540" alt="image" src="https://github.com/user-attachments/assets/4c365c06-6aa9-4471-9553-d46983ec66c7" >|<img width="540" alt="image" src="https://github.com/user-attachments/assets/d67723d9-fd79-4dcc-8451-f1537f8b3668" >|
- Add android-arm64 and android-x64 test cases to PublishNativeAOT and PublishNativeAOTRootAllMauiAssemblies tests - Add PrepareNativeAotBuildPropsAndroid() with Android-specific build properties including ANDROID_NDK_ROOT support - Add ExpectedNativeAOTWarningsAndroid baseline (XA1040 + IL3050 warnings) - Use OnlyAndroid() helper on Linux to avoid iOS/macCatalyst workload issues --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nd pixel-level comparison (dotnet#34024) <!-- 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! ### Root Cause `SafeAreaInsetsDidChange` fires repeatedly during iOS animations (e.g., `TranslateToAsync`, bottom sheet transitions) as views move relative to the window. This caused two distinct infinite loop patterns: 1. **Sub-pixel oscillation** (dotnet#32586, dotnet#33934): Animations produce sub-pixel differences in `SafeAreaInsets` (e.g., `0.0000001pt`). Exact equality fails, triggering `InvalidateAncestorsMeasures` → layout pass → position change → new `SafeAreaInsetsDidChange` → infinite loop. 2. **Parent-child double application** (dotnet#33595): A `ContentPage` (implementing `ISafeAreaView`) and its child `Grid` both independently apply safe area adjustments. When the `ContentPage` adjusts its layout for the notch/status bar, it repositions the `Grid`. The `Grid`'s new position fires `SafeAreaInsetsDidChange`, causing it to re-apply its own adjustment — creating a ping-pong loop. ### Description of Change **Primary fix — `IsParentHandlingSafeArea` (parent hierarchy walk):** In both `MauiView.ValidateSafeArea` and `MauiScrollView.ValidateSafeArea`, before applying safe area adjustments, we now check whether an ancestor `MauiView` is already applying safe area for the **same edges**. If so, the child skips its own adjustment to avoid double-padding. The check is **edge-aware**: a parent handling `Top` does not block a child from independently handling `Bottom`. Only overlapping edges cause deferral. The `_parentHandlesSafeArea` result is cached per layout cycle and cleared on `SafeAreaInsetsDidChange`, `InvalidateSafeArea`, and `MovedToWindow`. **Secondary fix — `EqualsAtPixelLevel`:** Safe area values are compared at device-pixel resolution (rounding to `1 / ContentScaleFactor`) before deciding whether to trigger a layout invalidation. This absorbs sub-pixel animation noise and prevents the oscillation loops in dotnet#32586 and dotnet#33934. **MauiScrollView bug fixes:** - Inverted condition: `!UpdateContentInsetAdjustmentBehavior()` was incorrectly gating behavior; corrected to `UpdateContentInsetAdjustmentBehavior()`. - The `_appliesSafeAreaAdjustments` flag now correctly incorporates `!IsParentHandlingSafeArea()`. **What was removed:** - The "Window Guard" approach (comparing `Window.SafeAreaInsets` to filter noise) was tried and removed. It was fragile: on macCatalyst with a custom TitleBar, `WindowViewController` repositions content by pushing it down, which changes the view's own `SafeAreaInsets` without changing `Window.SafeAreaInsets`. The guard blocked this legitimate change, causing a 28px content shift regression in CI. ### Issues Fixed Fixes dotnet#32586 Fixes dotnet#33934 Fixes dotnet#33595 Fixes dotnet#34042 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Tamilarasan-Paranthaman <Tamilarasan-Paranthaman@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 29041Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 29041" |
🤖 AI Summary📊 Expand Full Review🔍 Pre-Flight — Context & Validation📝 Review Session — Apply review recommendations: use EffectiveFlowDirection and unify RTL logic ·
|
| File | Type | Changes |
|---|---|---|
src/Controls/src/Core/Button/Button.iOS.cs |
Fix | +13/- unified Left/Right inset logic with RTL direction factor |
src/Controls/tests/TestCases.HostApp/Issues/Issue29036.cs |
Test (HostApp) | + 4-button test page (RTL+Left, LTR+Left, RTL+Right, LTR+Right) |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29036.cs |
Test (Shared) | + ButtonRTLTextAndImageShouldNotOverlap screenshot test |
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ButtonRTLTextAndImageShouldNotOverlap.png |
Snapshot | Added |
src/Controls/tests/TestCases.Android.Tests/snapshots/android/ButtonRTLTextAndImageShouldNotOverlap.png |
Snapshot | Added |
src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ButtonRTLTextAndImageShouldNotOverlap.png |
Snapshot | Added |
src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ButtonRTLTextAndImageShouldNotOverlap.png |
Snapshot | Added |
Fix Approach
Original code had separate centering + spacing blocks for ImagePosition.Left and ImagePosition.Right, without RTL awareness.
New code unifies both into one block using a direction factor:
nfloat dir = ((IVisualElementController)button).EffectiveFlowDirection.IsRightToLeft() ? -1 : 1;For RTL (dir=-1), all physical insets are reversed, correcting the overlap.
Key Concern
Potential regression for LTR + ImagePosition.Right: The new code applies the same net insets for both Left and Right positions in LTR mode. Original code had different net effects:
- LTR Left:
imageInsets.Left = -sharedSpacing(image moves slightly left) - LTR Right:
imageInsets.Left = titleWidth + sharedSpacing(image moves far right)
The new unified code gives -sharedSpacing for BOTH in LTR. This may cause LTR Right to look like LTR Left. The test page includes a LTR+Right button (button 4), so the screenshot test should catch this if broken.
PR Discussion Summary
- Bot auto-assigned reviewers (jsuarezruiz, rmarinho)
- Pipeline run triggered by reviewer
- PR was previously reviewed by the agent (labels: s/agent-approved, s/agent-fix-pr-picked)
- No inline code review comments or reviewer disagreements found
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #29041 | Multiply Left/Right insets by dir (-1 for RTL, 1 for LTR), unify Left+Right spacing PENDING (Gate) |
Button.iOS.cs (+13/-21) |
Original PR | blocks |
🚦 Gate — Test Verification
📝 Review Session — Apply review recommendations: use EffectiveFlowDirection and unify RTL logic · 9b79851
Result PASSED:
Platform: ios
Mode: Full Verification (RequireFullVerification: true)
- Tests FAIL without fix (correctly detects RTL overlap bug)
- Tests PASS with fix (fix resolves the issue)
Test: ButtonRTLTextAndImageShouldNotOverlap (Issue29036)
Device: iPhone Xs Simulator
Build Target: net10.0-ios26.0
🔧 Fix — Analysis & Comparison
📝 Review Session — Apply review recommendations: use EffectiveFlowDirection and unify RTL logic · 9b79851
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| 1 | try-fix | Algebraic simplification: remove redundant centering block, apply directly using MAUI | PASS | Button.iOS.cs (-13/+8) |
Cleaner than centering offsets cancel algebraically |
| 2 | try-fix | Same algebraic simplification using native iOS | PASS | Button.iOS.cs (-13/+8) |
Uses UIKit API instead of MAUI abstraction |
| 3 | try-fix | Swap Right effective position for RTL, then run original math FAIL | Button.iOS.cs |
12.52% visual doesn't cancel centering offsets correctly | diff unchanged |
| 4 | try-fix | Post-computation swap of imageInsets.Left/Right for FAIL | Button.iOS.cs |
13.41% visual same root cause as #3 | diff RTL |
| 5 | try-fix | Set UIButton.SemanticContentAttribute for RTL + algebraic FAIL |
Button.iOS.cs |
13.43% visual native attribute conflicts with manual positioning | diff spacing |
| 6 | try-fix | UIButton.Configuration (iOS 15+) with imagePlacement/imagePadding for FAIL |
Button.iOS.cs |
14.35% visual UIButton.Configuration produces different visual layout than legacy inset path | diff RTL |
| PR | PR #29041 | Unify Left+Right inset block, multiply all offsets by | PASS (Gate) | Button.iOS.cs (+13/-21) |
Original PR fix |
Cross-Pollination Summary
Round 1: All 5 models ran try-fix.
Round 2 (after Round 1):
| Model | Response |
|---|---|
| claude-sonnet-4.6 | NO NEW solution space exhausted for inset-based approaches |
| claude-opus-4.6 | NO NEW all algebraically correct fixes converge to same formula |
| tested as Attempt 6, FAILED | |
| same as above | |
| same as above |
Round 3 (after Attempt 6 failed):
| Model | Response |
|---|---|
| gpt-5.2 | NEW IDEA: Custom UIButton subclass overriding ImageRectForContentRect/TitleRectForContentRect |
| gpt-5.3-codex | NEW IDEA: Same UIButton subclass override approach |
| gemini-3-pro-preview | NEW IDEA: Override LayoutSubviews to manually set image/title frames |
Decision: UIButton subclass overrides are a major architectural refactor (not a targeted bug fix). Per skill guidelines ("Keep changes minimal", "Massive refactors to avoid"), these are noted as future architectural improvements but not implemented for this focused bug fix PR. Models 1 and 2 confirmed no further inset-based alternatives.
Exhausted: all viable minimal-change approaches exploredYes
Selected Fix: PR's both the PR's approach and Attempts #1/#2 pass tests. Attempt #1 is slightly cleaner (removes redundant centering block, fewer lines), but the PR's fix is also correct and has the advantage of preserving the structure of the original code more closely, making the intent (multiply by RTL direction) explicit.fix
Root Cause Analysis
The original LayoutButton method had a "centering block" that shifted image and title toward each other by half the other's width, plus separate spacing blocks for Left and Right positions. In RTL mode, the physical Left/Right directions are reversed, but the code applied the same positive/negative values regardless of flow direction, causing the image and title to overlap instead of separate.
The correct fix multiplies all horizontal offsets by a direction factor (-1 for RTL). As an insight: the centering block offsets algebraically cancel with the first terms of the spacing blocks, so the net effect is the algebraic simplification in Attempts #1 and #2.sharedSpacingsimply
📋 Report — Final Recommendation
📝 Review Session — Apply review recommendations: use EffectiveFlowDirection and unify RTL logic · 9b79851
Final Recommendation: APPROVE
Summary
PR #29041 fixes iOS Button RTL text/image overlap (issue #29036) by making the LayoutButton inset calculations RTL-aware. The fix is correct, well-tested, and passes Gate verification (tests fail without fix, pass with fix). The PR's fix is the best available minimal approach.
Root Cause
In Button.iOS.cs, the LayoutButton method positions the button image and title using UIEdgeInsets with physical left/right offsets. The original code applied these offsets identically regardless of flow direction. In RTL mode, iOS UIButton already mirrors its subview layout, so the MAUI inset designed for pushed image and title toward each other instead of away, causing overlap.LTRadjustments
Fix Quality
Approach: Multiply all horizontal inset adjustments by dir = IsRightToLeft ? -1 : 1, which reverses the direction of adjustments in RTL mode. The PR unifies the previously separate Left and Right position spacing blocks into a single block, which is correct because the algebraic net effect of both positions was sharedSpacing(the centering offsets cancel with the first term of the spacing offsets).always
Correctness confirmed by:
- Gate: Tests fail without fix (RTL overlap present), pass with fix
- Algebraic analysis: The centering block ( terms) algebraically cancels with the first half of the spacing terms, so unified treatment of Left and Right is mathematically equivalent to the original separate handling
- Alternative Attempt [Draft] Readme WIP #1 independently discovered this same algebraic simplification and also passed tests
Tests: 4-button test page covers RTL+Left, LTR+Left, RTL+Right, LTR+Right positions. Screenshot test captures all cases. Snapshots added for iOS, Android, Mac, Windows.
Fix Exploration (Phase 3)
| # | Approach | Result | Notes |
|---|---|---|---|
| 1 | Algebraic simplification: remove centering block, apply directly | PASS | Cleaner than PR (fewer lines), independently validated the algebraic insight |
| 2 | Same + native | PASS | Uses UIKit API; same net approach as #1 |
| 3 | Swap Right effective position for FAIL | 12.52% visual diff | RTL |
| 4 | Post-computation Left/Right inset FAIL | 13.41% visual diff | swap |
| 5 | SemanticContentAttribute + algebraic FAIL |
13. conflicts with manual positioning | 43% spacing |
| 6 | UIButton.Configuration (iOS 15+) FAIL |
14. different visual layout than legacy inset path | 35% API |
| PR | Unified -multiplied block PASS (Gate) | minimal targeted fix | Selected |
Selected Fix: PR's correct, minimal, and preserves the structure of the original method.fix
Alternative architectural path: All 3 remaining models proposed overriding ImageRectForContentRect/TitleRectForContentRect or LayoutSubviews on UIButton. These would eliminate manual inset math entirely but constitute a major architectural refactor outside the scope of this targeted bug fix.
PR Finalize Review
Title
Current: [iOS] Button RTL text and image overlap - fix
Suggested: [iOS] Button: Fix image/title inset math for RTL flow direction
(Removes redundant "-fix" suffix; verb "Fix" moves to the action; more descriptive of what changed)
Description
Current description is shows issue number and before/after images. Missing:minimal
- NOTE block (required for PR artifact testing)
- "Description of Change" section
- Root cause explanation (useful for future agents and reviewers)
Suggested additions:
<!-- 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!
### Description of Change
On iOS, `LayoutButton` in `Button.iOS.cs` applies `UIEdgeInsets` to position the button image and title for `ImagePosition.Left` and `ImagePosition.Right` using physical left/right offsets. These offsets were not aware of `FlowDirection`, so in RTL mode they pushed the image and title toward each other instead of apart, causing overlap.
**Fix:** Multiply all horizontal inset adjustments by a direction factor (`dir = IsRightToLeft ? -1 : 1`). In RTL mode this reverses all physical offsets, correctly separating image and title. The fix also unifies the previously separate `Left` and `Right` position this is safe because the centering offsets (`titleWidth/2`, `imageWidth/2`) algebraically cancel with the first term of each spacing block, so both positions net sharedSpacing`.to `blocks
**What NOT to do:**
Don't swap `Right` effective position for the centering block asymmetry means swapping produces wrong results (12-13% visual diff in testing)RTL Left-
Don't post-swap `imageInsets.Left`/`imageInsets.Right` after LTR same issuecomputation -
Don't use ` it changes native UIKit layout in ways that conflict with manual inset positioningSemanticContentAttribute` -
Don't use `UIButton.Configuration` API for this it produces a different visual layout than the legacy `imageEdgeInsets`/`titleEdgeInsets` path that MAUI currently usesfix -
### Issues Fixed
Fixes https://github.com/dotnet/maui/issues/29036
[existing before/after images here]Code Review Findings
** Looks Good:**
-
EffectiveFlowDirectioncorrectly handles both explicit and inherited RTL from parent elements -
Test page covers all 4 cases: RTL+Left, LTR+Left, RTL+Right, LTR+Right
-
PlatformAffected.iOSattribute correctly scopes the issue -
Snapshots provided for all platforms (iOS, Android, Mac, Windows)
-
Fix is minimal and only touches the affected code pathtargeted
-
The comment
// These are just used to shift the image and title to center / // Which makes the later math easier to followwas written for the old structure where centering and spacing were separate blocks. Now that both are combined in the unified block, this comment is slightly misleading. Suggest updating to something like:// Adjust image and title insets for horizontal positions. In RTL mode, physical offsets are reversed.**
No critical issues found. The fix is correct and the math has been independently validated.
📋 Expand PR Finalization Review
Title: ✅ Good
Current: [iOS] Button RTL text and image overlap - fix
Description: ⚠️ Needs Update
- fixsuffix is informal and non-standard; it reads like a noun phrase with a tacked-on suffix rather than a concise action description- The platform prefix
[iOS]is correct since onlyButton.iOS.csis changed - The description is vague — doesn't capture the root cause or fix approach
✨ Suggested PR Description
[!NOTE]
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
On iOS, LayoutButton() computes UIEdgeInsets for the image and title using physical Left/Right offsets. The original code assumed LTR layout throughout — it never checked FlowDirection. In RTL mode, the inset offsets moved the image and title in the wrong physical direction, causing them to overlap rather than separate.
Description of Change
Button.iOS.cs — LayoutButton() (ImagePosition.Left / ImagePosition.Right):
Introduced a dir factor (+1 for LTR, -1 for RTL) using EffectiveFlowDirection.IsRightToLeft(). All Left/Right inset adjustments are now multiplied by dir, so the image and title are nudged apart in the correct physical direction regardless of flow direction. EffectiveFlowDirection captures both explicit FlowDirection settings and inherited RTL from parent containers.
The two separate else if spacing blocks for ImagePosition.Left and ImagePosition.Right were consolidated into the shared block, simplifying the code path.
Tests added:
TestCases.HostApp/Issues/Issue29036.cs— 4-button test page: RTL+Left, LTR+Left, RTL+Right, LTR+Right image positionsTestCases.Shared.Tests/Tests/Issues/Issue29036.cs— screenshot regression test (ButtonRTLTextAndImageShouldNotOverlap)- Snapshot baselines for iOS, Android, Mac, and Windows
Issues Fixed
Fixes #29036
Platforms Tested
- iOS (primary — fix is in
Button.iOS.cs) - Android (snapshot baseline added)
- Mac Catalyst (snapshot baseline added)
- Windows (snapshot baseline added)
Code Review: ✅ Passed
Code Review — PR #29041
🟡 Suggestions (Non-Blocking)
1. Redundant Math Makes Code Hard to Audit
File: src/Controls/src/Core/Button/Button.iOS.cs
Problem: The 8 inset assignments in lines 211–219 cancel each other down algebraically. The net effect for each inset is simply ±dir * sharedSpacing:
imageInsets.Left → dir*(titleWidth/2) - dir*(titleWidth/2 + sharedSpacing) = -dir * sharedSpacing
imageInsets.Right → +dir * sharedSpacing
titleInsets.Left → +dir * sharedSpacing
titleInsets.Right → -dir * sharedSpacing
Recommendation: Simplify to make the intent immediately clear:
nfloat dir = ((IVisualElementController)button).EffectiveFlowDirection.IsRightToLeft() ? -1 : 1;
imageInsets.Left -= dir * sharedSpacing;
imageInsets.Right += dir * sharedSpacing;
titleInsets.Left += dir * sharedSpacing;
titleInsets.Right -= dir * sharedSpacing;This is functionally identical and easier to verify. Not a blocker since the current code is correct.
2. Left vs. Right Image Position Now Produce the Same Net Insets
File: src/Controls/src/Core/Button/Button.iOS.cs
Observation: The old code produced different net inset values for ImagePosition.Left vs ImagePosition.Right in LTR mode (the Right block had opposite-sign spacing). The new unified block produces the same result for both. This is a behavioral change for ImagePosition.Right in LTR.
Snapshot tests for LTR+Right are committed, validating the new visual output, and the old Right behavior may itself have been incorrect. Not a blocker, but reviewers should be aware of the behavioral scope.
3. Minor: PlatformAffected Annotation Inconsistent with Test Coverage
File: src/Controls/tests/TestCases.HostApp/Issues/Issue29036.cs
Observation:
[Issue(IssueTracker.Github, 29036, "Button RTL text and image overlap", PlatformAffected.iOS)]Snapshot baselines were committed for Android, Mac, and Windows. Since the actual fix is iOS-only, PlatformAffected.iOS is accurate, but the test runs cross-platform. This is a minor inconsistency, not a functional issue.
✅ Looks Good
EffectiveFlowDirection.IsRightToLeft()correctly captures both explicit and inherited RTL — the right API to use hereIVisualElementControllercast follows the established MAUI pattern for flow direction queries- Test page covers all 4 meaningful button variants: RTL+Left, LTR+Left, RTL+Right, LTR+Right
- Snapshot baselines committed for all 4 platforms
- Comment on
dirclearly explains the RTL reversal intent - Top/Bottom image positions are unaffected — the change is surgical
…L logic - Replace button.FlowDirection == FlowDirection.RightToLeft with EffectiveFlowDirection.IsRightToLeft() to handle inherited RTL (e.g., button inside RTL parent with FlowDirection.MatchParent) - Use direction multiplier to eliminate 3 duplicate if/else blocks - Merge identical ImagePosition.Left/Right spacing blocks - Add missing trailing newlines to test files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
### Issues Fixed Fixes #29036 |Before|After| |--|--| |<img src="https://github.com/user-attachments/assets/f9415ea5-cfe2-4b0b-a89d-3c09e80bc896" width="300px"/>|<img src="https://github.com/user-attachments/assets/4b503920-b1d0-4bd6-9329-6777467130f1" width="300px"/>|
### Issues Fixed Fixes #29036 |Before|After| |--|--| |<img src="https://github.com/user-attachments/assets/f9415ea5-cfe2-4b0b-a89d-3c09e80bc896" width="300px"/>|<img src="https://github.com/user-attachments/assets/4b503920-b1d0-4bd6-9329-6777467130f1" width="300px"/>|
### Issues Fixed Fixes #29036 |Before|After| |--|--| |<img src="https://github.com/user-attachments/assets/f9415ea5-cfe2-4b0b-a89d-3c09e80bc896" width="300px"/>|<img src="https://github.com/user-attachments/assets/4b503920-b1d0-4bd6-9329-6777467130f1" width="300px"/>|
### Issues Fixed Fixes #29036 |Before|After| |--|--| |<img src="https://github.com/user-attachments/assets/f9415ea5-cfe2-4b0b-a89d-3c09e80bc896" width="300px"/>|<img src="https://github.com/user-attachments/assets/4b503920-b1d0-4bd6-9329-6777467130f1" width="300px"/>|
This reverts commit d15854a.
### Issues Fixed Fixes #29036 |Before|After| |--|--| |<img src="https://github.com/user-attachments/assets/f9415ea5-cfe2-4b0b-a89d-3c09e80bc896" width="300px"/>|<img src="https://github.com/user-attachments/assets/4b503920-b1d0-4bd6-9329-6777467130f1" width="300px"/>|
This reverts commit d15854a.
This reverts commit d15854a.
This reverts commit d15854a.
## What's Coming .NET MAUI inflight/candidate introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 66 commits with various improvements, bug fixes, and enhancements. ## Activityindicator - [Android] Implemented material3 support for ActivityIndicator by @Dhivya-SF4094 in #33481 <details> <summary>🔧 Fixes</summary> - [Implement material3 support for ActivityIndicator](#33479) </details> - [iOS] Fix: ActivityIndicator IsRunning ignores IsVisible when set to true by @bhavanesh2001 in #28983 <details> <summary>🔧 Fixes</summary> - [[iOS] [ActivityIndicator] `IsRunning` ignores `IsVisible` when set to `true`](#28968) </details> ## Button - [iOS] Button RTL text and image overlap - fix by @kubaflo in #29041 ## Checkbox - [iOS/MacCatalyst] Fix CheckBox foreground color not resetting when set to null by @Ahamed-Ali in #34284 <details> <summary>🔧 Fixes</summary> - [[iOS] Color of the checkBox control is not properly worked on dynamic scenarios](#34278) </details> ## CollectionView - [iOS] Fix: CollectionView does not clear selection when SelectedItem is set to null by @Tamilarasan-Paranthaman in #30420 <details> <summary>🔧 Fixes</summary> - [CollectionView not being able to remove selected item highlight on iOS](#30363) - [[MAUI] Select items traces are preserved](#26187) </details> - [iOS] CV2 ItemsLayout update by @kubaflo in #28675 <details> <summary>🔧 Fixes</summary> - [CollectionView CollectionViewHandler2 doesnt change ItemsLayout on DataTrigger](#28656) - [iOS CollectionView doesn't respect a change to ItemsLayout when using Items2.CollectionViewHandler2](#31259) </details> - [iOS][CV2] Fix CollectionView renders large empty space at bottom of view by @devanathan-vaithiyanathan in #31215 <details> <summary>🔧 Fixes</summary> - [[iOS] [MacCatalyst] CollectionView renders large empty space at bottom of view](#17799) - [[iOS/Mac] CollectionView2 EmptyView takes up large horizontal space even when the content is small](#33201) </details> - [iOS] Fixed issue where group Header/Footer template was set to all items when IsGrouped was true for an ObservableCollection by @Tamilarasan-Paranthaman in #29144 <details> <summary>🔧 Fixes</summary> - [[iOS] Group Header/Footer Repeated for All Items When IsGrouped is True for ObservableCollection in CollectionView](#29141) </details> - [Android] Fix CollectionView selection crash with HeaderTemplate by @NirmalKumarYuvaraj in #34275 <details> <summary>🔧 Fixes</summary> - [[Bug] [Android] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index](#34247) </details> ## DateTimePicker - [iOS] Fix TimePicker AM/PM frequently changes when the app is closed and reopened by @devanathan-vaithiyanathan in #31066 <details> <summary>🔧 Fixes</summary> - [[iOS] TimePicker AM/PM frequently changes when the app is closed and reopened](#30837) - [Maui 10 iOS TimePicker Strange Characters in place of AM/PM](#33722) </details> - Android TimePicker ignores 24 hour system setting when using Format Property - fix by @kubaflo in #28797 <details> <summary>🔧 Fixes</summary> - [Android TimePicker ignores 24 hour system setting when using Format Property](#28784) </details> ## Drawing - [iOS, Mac, Windows] GraphicsView: Fix Background/BackgroundColor not updating by @NirmalKumarYuvaraj in #31254 <details> <summary>🔧 Fixes</summary> - [[iOS, Mac, Windows] GraphicsView does not change the Background/BackgroundColor](#31239) </details> - [iOS] GraphicsView DrawString - fix by @kubaflo in #26304 <details> <summary>🔧 Fixes</summary> - [DrawString not rendering in iOS.](#24450) - [GraphicsView DrawString not rendering in iOS](#8486) - [DrawString doesn't work on maccatalyst](#4993) </details> - [Android] - Fix Shadow Rendering For Transparent Fill, Stroke (Lines), and Text on Shapes by @prakashKannanSf3972 in #29528 <details> <summary>🔧 Fixes</summary> - [Ellipse Transparency Not Rendered When Drawing Arc Inside the Ellipse Using GraphicsView on Android](#29394) </details> - Revert "[iOS, Mac, Windows] GraphicsView: Fix Background/BackgroundColor not updating (#31254)" by @Ahamed-Ali via @Copilot in #34508 ## Entry - [iOS 26] Fix Entry MaxLength not enforced due to new multi-range delegate by @kubaflo in #32045 <details> <summary>🔧 Fixes</summary> - [iOS 26 - The MaxLength property value is not respected on an Entry control.](#32016) - [.NET MAUI Entry Maximum Length not working on iOS and macOS](#33316) </details> - [iOS] Fixed Entry with IsPassword toggling loses previously entered text by @SubhikshaSf4851 in #30572 <details> <summary>🔧 Fixes</summary> - [Entry with IsPassword toggling loses previously entered text on iOS when IsPassword is re-enabled](#30085) </details> ## Essentials - Fix for FilePicker PickMultipleAsync nullable reference type by @SuthiYuvaraj in #33163 <details> <summary>🔧 Fixes</summary> - [FilePicker PickMultipleAsync nullable reference type](#33114) </details> - Replace deprecated NetworkReachability with NWPathMonitor on iOS/macOS by @jfversluis via @Copilot in #32354 <details> <summary>🔧 Fixes</summary> - [NetworkReachability is obsolete on iOS/maccatalyst 17.4+](#32312) - [Use NWPathMonitor on iOS for Essentials Connectivity](#2574) </details> ## Essentials Connectivity - Update Android Connectivity implementation to use modern APIs by @jfversluis via @Copilot in #30348 <details> <summary>🔧 Fixes</summary> - [Update the Android Connectivity implementation to user modern APIs](#30347) </details> ## Flyout - [iOS] Fixed Flyout icon not updating when root page changes using InsertPageBefore by @Vignesh-SF3580 in #29924 <details> <summary>🔧 Fixes</summary> - [[iOS] Flyout icon not replaced by back button when root page is changed using InsertPageBefore](#29921) </details> ## Flyoutpage - [iOS] Flyout Items Not Displayed in RightToLeft FlowDirection in Landscape - fix by @kubaflo in #26762 <details> <summary>🔧 Fixes</summary> - [Flyout Items Not Displayed in RightToLeft FlowDirection on iOS in Landscape Orientation and Hamburger Icon Positioned Incorrectly](#26726) </details> ## Image - [Android] Implemented Material3 support for Image by @Dhivya-SF4094 in #33661 <details> <summary>🔧 Fixes</summary> - [Implement Material3 support for Image](#33660) </details> ## Keyboard - [iOS] Fix gap at top of view after rotating device while Entry keyboard is visible by @praveenkumarkarunanithi in #34328 <details> <summary>🔧 Fixes</summary> - [Focusing and entering texts on entry control causes a gap at the top after rotating simulator.](#33407) </details> ## Label - [Android] Support for images inside HTML label by @kubaflo in #21679 <details> <summary>🔧 Fixes</summary> - [Label with HTML TextType does not display images on Android](#21044) </details> - [fix] ContentLabel Moved to a nested class to prevent CS0122 in external source generators by @SubhikshaSf4851 in #34514 <details> <summary>🔧 Fixes</summary> - [[MAUI] Building Maui App with sample content results CS0122 errors.](#34512) </details> ## Layout - Optimize ordering of children in Flex layout by @symbiogenesis in #21961 - [Android] Fix control size properties not available during Loaded event by @Vignesh-SF3580 in #31590 <details> <summary>🔧 Fixes</summary> - [CollectionView on Android does not provide height, width, logical children once loaded, works fine on Windows](#14364) - [Control's Loaded event invokes before calling its measure override method.](#14160) </details> ## Mediapicker - [iOS/Android] MediaPicker: Fix image orientation when RotateImage=true by @michalpobuta in #33892 <details> <summary>🔧 Fixes</summary> - [MediaPicker.PickPhotosAsync does not preserve image orientation](#32650) </details> ## Modal - [Windows] Fix modal page keyboard focus not shifting to newly opened modal by @jfversluis in #34212 <details> <summary>🔧 Fixes</summary> - [Keyboard focus does not shift to a newly opened modal page: Pressing enter clicks the button on the page beneath the modal page](#22938) </details> ## Navigation - [iOS26] Apply view margins in title view by @kubaflo in #32205 <details> <summary>🔧 Fixes</summary> - [NavigationPage TitleView iOS 26](#32200) </details> - [iOS] System.NullReferenceException at NavigationRenderer.SetStatusBarStyle() by @kubaflo in #29564 <details> <summary>🔧 Fixes</summary> - [System.NullReferenceException at NavigationRenderer.SetStatusBarStyle()](#29535) </details> - [iOS 26] Fix back button color not applied for NavigationPage by @Shalini-Ashokan in #34326 <details> <summary>🔧 Fixes</summary> - [[iOS] Color not applied to the Back button text or image on iOS 26](#33966) </details> ## Picker - Fix Picker layout on Mac Catalyst 26+ by @kubaflo in #33146 <details> <summary>🔧 Fixes</summary> - [[MacOS 26] Text on picker options are not centered on macOS 26.1](#33229) </details> ## Progressbar - [Android] Implemented Material3 support for ProgressBar by @SyedAbdulAzeemSF4852 in #33926 <details> <summary>🔧 Fixes</summary> - [Implement Material3 support for Progressbar](#33925) </details> ## RadioButton - [iOS, Mac] Fix for RadioButton TextColor for plain Content not working by @HarishwaranVijayakumar in #31940 <details> <summary>🔧 Fixes</summary> - [RadioButton: TextColor for plain Content not working on iOS](#18011) </details> - [All Platforms] Fix RadioButton warning when ControlTemplate is set with View content by @kubaflo in #33839 <details> <summary>🔧 Fixes</summary> - [Seeking clarification on RadioButton + ControlTemplate + Content documentation](#33829) </details> - Visual state change for disabled RadioButton by @kubaflo in #23471 <details> <summary>🔧 Fixes</summary> - [RadioButton disabled UI issue - iOS](#18668) </details> ## SafeArea - [Android] Fix for TabbedPage BottomNavigation BarBackgroundColor not extending to system navigation bar by @praveenkumarkarunanithi in #33428 <details> <summary>🔧 Fixes</summary> - [[Android] TabbedPage BottomNavigation BarBackgroundColor does not extend to system navigation bar area in Edge-to-Edge mode](#33344) </details> ## ScrollView - [Android] ScrollView: Fix HorizontalScrollBarVisibility not updating immediately at runtime by @SubhikshaSf4851 in #33528 <details> <summary>🔧 Fixes</summary> - [Runtime Scrollbar visibility not updating correctly on Android and macOS platforms.](#33400) </details> - Fixed crash when calling ItemsView.ScrollTo on unloaded CollectionView by @kubaflo in #25444 <details> <summary>🔧 Fixes</summary> - [App crashes when calling ItemsView.ScrollTo on unloaded CollectionView](#23014) </details> ## Shell - [Shell] Update logic for iOS large title display in ShellItemRenderer by @kubaflo in #33246 - [iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs) by @kubaflo in #27932 <details> <summary>🔧 Fixes</summary> - [OnAppearing and OnNavigatedTo does not work when using extended Tabbar (tabbar with more than 5 tabs) on IOS.](#27799) - [Shell.BackButtonBehavior does not work when using extended Tabbar (tabbar with more than 5 tabs)on IOS.](#27800) - [Shell TabBar More button causes ViewModel command binding disconnection on back navigation](#30862) - [Content page onappearing not firing if tabs are on the more tab on IOS](#31166) </details> - [iOS 26] Fix tab bar ghosting when navigating from modal to tabbed Shell content by @SubhikshaSf4851 in #34254 <details> <summary>🔧 Fixes</summary> - [[iOS] Tab bar ghosting issue on iOS 26 (liquid glass)](#34143) </details> - Fix for Shell tab visibility not updating when navigating back multiple pages by @BagavathiPerumal in #34403 <details> <summary>🔧 Fixes</summary> - [Changing Shell Tab Visibility when navigating back multiple pages ignores Shell Tab Visibility](#33351) </details> - [iOS/Mac] Fixed OnBackButtonPressed not firing for Shell Navigation Bar Button by @Dhivya-SF4094 in #34401 <details> <summary>🔧 Fixes</summary> - [[iOS] OnBackButtonPressed not firing for Shell Navigation Bar button](#34190) </details> ## Slider - [iOS] Fix for Slider ThumbImageSource is not centered properly on iOS 26 by @HarishwaranVijayakumar in #34019 <details> <summary>🔧 Fixes</summary> - [[iOS 26] Slider ThumbImageSource is not centered properly](#33967) </details> - [Android] Fix improper rendering of ThumbimageSource in Slider by @NirmalKumarYuvaraj in #34064 <details> <summary>🔧 Fixes</summary> - [[Slider] MAUI Slider thumb image is big on android](#13258) </details> ## Stepper - [iOS] Fix Stepper layout overlap in landscape on iOS 26 by @Vignesh-SF3580 in #34325 <details> <summary>🔧 Fixes</summary> - [[.NET10] D10 - Customize cursor position - Rotating simulator makes the button and label overlap](#34273) </details> ## SwipeView - [iOS] SwipeView: Honor FontImageSource.Color in SwipeItem icon by @kubaflo in #27389 <details> <summary>🔧 Fixes</summary> - [[iOS] SwipeView: SwipeItem.IconImageSource.FontImageSource color value not honored](#27377) </details> ## Switch - [Android] Fix Switch thumb shadow missing when ThumbColor is set by @Shalini-Ashokan in #33960 <details> <summary>🔧 Fixes</summary> - [Android Switch Control Thumb Shadow](#19676) </details> ## Toolbar - [iOS/Mac Catalyst 26] Fix Shell.ForegroundColor not applied to ToolbarItems by @SyedAbdulAzeemSF4852 in #34085 <details> <summary>🔧 Fixes</summary> - [[iOS26] Shell.ForegroundColor is not applied to ToolbarItems](#34083) </details> - [Android] VoiceOver on Toolbar Item by @kubaflo in #29596 <details> <summary>🔧 Fixes</summary> - [VoiceOver on Toolbar Item](#29573) - [SemanticProperties do not work on ToolbarItems](#23623) </details> <details> <summary>🧪 Testing (11)</summary> - [Testing] Additional Feature Matrix Test Cases for CollectionView by @TamilarasanSF4853 in #32432 - [Testing] Feature Matrix UITest Cases for VisualStateManager by @LogishaSelvarajSF4525 in #34146 - [Testing] Feature Matrix UITest Cases for Clip by @TamilarasanSF4853 in #34121 - [Testing] Feature matrix UITest Cases for Map Control by @HarishKumarSF4517 in #31656 - [Testing] Feature matrix UITest Cases for Visual Transform Control by @HarishKumarSF4517 in #32799 - [Testing] Feature Matrix UITest Cases for Shell Pages by @NafeelaNazhir in #33945 - [Testing] Feature Matrix UITest Cases for Triggers by @HarishKumarSF4517 in #34152 - [Testing] Refactoring Feature Matrix UITest Cases for CheckBox Control by @LogishaSelvarajSF4525 in #34283 - Resolve UI test Build Sample failures - Candidate March 16 by @Ahamed-Ali in #34442 - Fix the failures in the Candidate branch- March 16 by @Ahamed-Ali in #34453 <details> <summary>🔧 Fixes</summary> - [March 16th, Candidate](#34437) </details> - Fixed the iOS 18.5 Candidate failures (March 16,2026) by @Ahamed-Ali in #34593 <details> <summary>🔧 Fixes</summary> - [March 16th, Candidate](#34437) </details> </details> <details> <summary>📦 Other (2)</summary> - Fixed candidate test failures caused by PR #33428. by @Ahamed-Ali in #34515 <details> <summary>🔧 Fixes</summary> - [[.NET10] On Android, there's a big space at the top for I, M and N2 & N3](#34509) </details> - Revert "[iOS] Button RTL text and image overlap - fix (#29041)" in b0497af </details> <details> <summary>📝 Issue References</summary> Fixes #2574, Fixes #4993, Fixes #8486, Fixes #13258, Fixes #14160, Fixes #14364, Fixes #17799, Fixes #18011, Fixes #18668, Fixes #19676, Fixes #21044, Fixes #22938, Fixes #23014, Fixes #23623, Fixes #24450, Fixes #26187, Fixes #26726, Fixes #27377, Fixes #27799, Fixes #27800, Fixes #28656, Fixes #28784, Fixes #28968, Fixes #29141, Fixes #29394, Fixes #29535, Fixes #29573, Fixes #29921, Fixes #30085, Fixes #30347, Fixes #30363, Fixes #30837, Fixes #30862, Fixes #31166, Fixes #31239, Fixes #31259, Fixes #32016, Fixes #32200, Fixes #32312, Fixes #32650, Fixes #33114, Fixes #33201, Fixes #33229, Fixes #33316, Fixes #33344, Fixes #33351, Fixes #33400, Fixes #33407, Fixes #33479, Fixes #33660, Fixes #33722, Fixes #33829, Fixes #33925, Fixes #33966, Fixes #33967, Fixes #34083, Fixes #34143, Fixes #34190, Fixes #34247, Fixes #34273, Fixes #34278, Fixes #34437, Fixes #34509, Fixes #34512 </details> **Full Changelog**: main...inflight/candidate
### Issues Fixed Fixes dotnet#29036 |Before|After| |--|--| |<img src="https://github.com/user-attachments/assets/f9415ea5-cfe2-4b0b-a89d-3c09e80bc896" width="300px"/>|<img src="https://github.com/user-attachments/assets/4b503920-b1d0-4bd6-9329-6777467130f1" width="300px"/>|
Issues Fixed