Skip to content

Fixed Editor HorizontalTextAlignment does not update at run time#25129

Merged
kubaflo merged 28 commits intodotnet:inflight/currentfrom
NirmalKumarYuvaraj:fix-10987
Mar 26, 2026
Merged

Fixed Editor HorizontalTextAlignment does not update at run time#25129
kubaflo merged 28 commits intodotnet:inflight/currentfrom
NirmalKumarYuvaraj:fix-10987

Conversation

@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor

@NirmalKumarYuvaraj NirmalKumarYuvaraj commented Oct 8, 2024

Root Cause

Android
The text alignment property of the Android EditText does not update at runtime, causing the text alignment to remain unchanged.

iOS and MAC

Runtime changes to vertical text alignment are not handled for placeholders on both iOS and macOS platforms. As a result, the placeholder text remains at the start position. Additionally, horizontal text alignment is not supported for placeholder label.

Description of Change

Android

We can resolve this issue by using gravity along with the text alignment logic.

iOS and MAC

For vertical text alignment, we can relayout the placeholder label whenever the value changes. Since MauiTextView is derived from UITextView, we can override the TextAlignmentProperty and set its value directly to UITextView. At the same time, we can apply the same value to the placeholder label. This ensures that both the text view and the placeholder label are perfectly aligned.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #10987
Fixes #30052

Output

Before After
Android.-.Before.mp4
Android.-.After.mp4
IOS.-Before.mp4
IOS-After.mp4
MAC.before.mp4
MAC.after.mp4

Windows

working fine in windows platform.

Windows.mp4

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@NirmalKumarYuvaraj NirmalKumarYuvaraj marked this pull request as ready for review October 10, 2024 12:21
@NirmalKumarYuvaraj NirmalKumarYuvaraj requested a review from a team as a code owner October 10, 2024 12:21
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

/rebase

@jsuarezruiz
Copy link
Copy Markdown
Contributor

jsuarezruiz commented Oct 11, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

1 similar comment
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Copy Markdown
Contributor

jsuarezruiz commented Oct 28, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 9 Servicing milestone Oct 31, 2024
@dotnet dotnet deleted a comment from azure-pipelines bot Nov 11, 2024
@sheiksyedm
Copy link
Copy Markdown
Contributor

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

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

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

Or

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

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

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

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

Or

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

@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

@kubaflo , Addressed test case failure.

@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 24, 2026

🤖 AI Summary

📊 Expand Full Reviewa3f2f52 · replaced android images
🔍 Pre-Flight — Context & Validation

Issue: #10987 - Editor HorizontalTextAlignment Does not Works.
Related Issue: #30052 - [iOS/MacOs] Right-To-Left (RTL) alignment is not applied to Editor placeholder
PR: #25129 - Fixed Editor HorizontalTextAlignment does not update at run time
Platforms Affected: Android (#10987), iOS/macOS (#30052)
Files Changed: 6 implementation, 15 test

Key Findings

  • The PR bundles two behavioral fixes: Android runtime Editor.HorizontalTextAlignment updates and iOS/macOS placeholder alignment/runtime relayout behavior.
  • Android issue Editor HorizontalTextAlignment Does not Works. #10987 is explicitly reproducible on Android; the PR adds a dedicated HostApp page and UITest pair (Issue10987) for runtime alignment changes.
  • Review discussion requested RTL coverage, snapshot refreshes, and PublicAPI corrections; the current diff includes RTL coverage, refreshed snapshots, and PublicAPI.Unshipped.txt updates.
  • There are still unresolved review concerns on the iOS/macOS side: service-release API surface risk around overriding MauiTextView.TextAlignment, a prior macOS test failure (Expected: Left, Actual: Natural), and a later concern that changing _ => ContentOffset to _ => default in ShouldCenterVertically() may be unrelated.
  • Prior agent review content was found in PR comments and imported for context; it also concluded the PR mixed Android and iOS/macOS concerns and flagged the unresolved iOS/macOS review threads.

Edge Cases / Reviewer Notes

  • Reviewer requested RTL coverage in the reproduction scenario; the HostApp issue page now includes both LTR and RTL editors.
  • Screenshot baselines had to be refreshed for macOS and Android because of unrelated screenshot pipeline changes.
  • Reviewers requested moving PublicAPI additions to Unshipped.txt, which the current diff does.
  • The PR currently shows failing checks overall, although many sub-checks are green; unresolved review threads remain open.

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #25129 Android: update runtime editor alignment by applying both TextAlignment and Gravity; iOS/macOS: relayout placeholder and sync placeholder text alignment via MauiTextView changes ⏳ PENDING (Gate) src/Core/src/Platform/Android/TextAlignmentExtensions.cs, src/Core/src/Handlers/Editor/EditorHandler.Android.cs, src/Core/src/Platform/iOS/MauiTextView.cs, src/Core/src/Platform/iOS/TextViewExtensions.cs, test files and snapshots Original PR; combines Android fix with broader iOS/macOS behavior changes

🚦 Gate — Test Verification

Gate Result: ⚠️ SKIPPED

Platform: android
Mode: Full Verification

  • Tests FAIL without fix: ❌ Unable to determine (deployment blocked)
  • Tests PASS with fix: ❌ Not reached

Evidence

  • verify-tests-fail-without-fix was invoked through an isolated task agent as required.
  • The skill successfully identified PR Fixed Editor HorizontalTextAlignment does not update at run time #25129, reverted the detected fix files to establish the pre-fix state, built the HostApp, and detected Android emulator emulator-5554.
  • Verification stopped before test execution because app deployment to the emulator failed with ADB0010 / Mono.AndroidTools.InstallFailedException: Unexpected install output: cmd: Failure calling service package: Broken pipe (32).
  • Because the without-fix run never reached actual test execution, the with-fix run was not attempted.

Final Status

Gate is skipped due to Android environment/deployment failure rather than a demonstrated pass/fail result for the PR.


🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) Override MapHorizontalTextAlignment in EditorHandler.Android.cs to explicitly set both TextAlignment and Gravity, preserving vertical gravity ✅ PASS 1 file Narrower Android-only change; simplest passing candidate
2 try-fix (claude-sonnet-4.6) Use TextAlignment.Gravity and drive alignment purely through gravity flags in EditTextExtensions.cs ❌ FAIL 1 file Breaks RTL behavior; ViewStart/ViewEnd still required
3 try-fix (gpt-5.3-codex) Reapply alignment in EditorHandler.Android on next UI turn via Post() plus layout invalidation ❌ FAIL 1 file Timing workaround still missed visual baselines
4 try-fix (gemini-3-pro-preview) Override MapHorizontalTextAlignment in EditorHandler.Android.cs to explicitly set gravity and force RequestLayout() ✅ PASS 1 file Android-only; slightly heavier than candidate #1
5 try-fix (round 2) Store alignment in MauiAppCompatEditText and reapply in OnAttachedToWindow ✅ PASS 3 files Works, but adds platform-view lifecycle state and new Android API surface
6 try-fix (round 3) Re-sync gravity from TextAlignment during MauiAppCompatEditText.OnLayout ✅ PASS 2 files Reactive native workaround; broader lifecycle coupling than candidate #1
7 try-fix (round 3) Apply AlignmentSpanStandard to text/hint instead of using view gravity ❌ FAIL 4 files Paragraph-direction alignment conflicts with RTL view-direction expectations
8 try-fix (round 3) Preserve MAUI horizontal bits by intercepting Android gravity mutation in MauiAppCompatEditText ❌ FAIL 2 files Not viable with current Android binding/API shape
PR PR #25129 Update shared Android text alignment helper to always set both TextAlignment and Gravity; plus iOS/macOS placeholder changes ⚠️ PENDING (Gate skipped on Android) 4 implementation files + tests/snapshots Original PR bundles Android and iOS/macOS changes; unresolved iOS/macOS review concerns remain

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 1 Yes Handler-scoped Android fix candidate completed
claude-sonnet-4.6 1 Yes Gravity-delegation variant failed because RTL mapping broke
gpt-5.3-codex 1 Yes Deferred reapply/layout invalidation variant failed visual verification
gemini-3-pro-preview 1 Yes Handler-scoped gravity + RequestLayout() candidate completed
claude-opus-4.6 2 No NO NEW IDEAS beyond handler-scoped solution family
claude-sonnet-4.6 2 Yes New platform-view lifecycle idea tested as candidate #5
gpt-5.3-codex 2 No NO NEW IDEAS after failed timing workaround
gemini-3-pro-preview 2 No NO NEW IDEAS beyond explicit handler gravity application
claude-opus-4.6 3 Yes New native layout-pipeline idea tested as candidate #6 after OnRtlPropertiesChanged proved unavailable
claude-sonnet-4.6 3 Yes New AlignmentSpan idea tested as candidate #7 and failed
gpt-5.3-codex 3 Yes New gravity-preservation interception idea tested as candidate #8 and failed
gemini-3-pro-preview 3 No NO NEW IDEAS

Best Fix Comparison

Candidate Passes Tests Files Scope Risks
PR Unknown on Android gate; CI overall failing 4 impl + tests Android + iOS/macOS Mixes concerns; unresolved iOS/macOS review/API questions
#1 Yes 1 Android Editor only Does not generalize to other EditText-based controls
#4 Yes 1 Android Editor only Adds extra layout forcing; more churn than #1
#5 Yes 3 Android Editor platform view Adds state/lifecycle code and Android API surface
#6 Yes 2 Android Editor platform view Couples behavior to every layout pass

Exhausted: Yes
Selected Fix: Candidate #1 — it passed Android validation, changes only EditorHandler.Android.cs, avoids shared-helper regressions, and avoids the PR's unrelated iOS/macOS surface area.


📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE PR mixes Android fix for #10987 with iOS/macOS placeholder changes for #30052; unresolved iOS/macOS review threads remain
Gate ⚠️ SKIPPED Android full verification was blocked by ADB install failure (Broken pipe) before tests ran
Try-Fix ✅ COMPLETE 8 attempts, 4 passing; independent Android-only alternatives found
Report ✅ COMPLETE

Summary

The Android bug has multiple working fixes, but the best one I found is a smaller Android-only handler change than the PR. Because the PR bundles that Android behavior change together with broader iOS/macOS work that still has open concerns, I would request changes rather than approve this version.

Root Cause

On Android, changing Editor.HorizontalTextAlignment at runtime needs both parts of Android's rendering state updated: the view's TextAlignment for correct RTL-aware semantics and the horizontal Gravity bits for actual placement. Updating only one side leaves the editor visually stale or breaks RTL behavior.

Fix Quality

The PR's Android direction is plausible, but it changes the shared Android text-alignment helper and ships unrelated iOS/macOS placeholder/runtime changes in the same PR. My try-fix exploration found four Android-only passing candidates, with candidate #1 the strongest: it fixes the bug by updating EditorHandler.Android.cs only, keeping the blast radius to Editor instead of every EditText-based control. That makes the current PR harder to justify as-is, especially with unresolved iOS/macOS review/API concerns still present.


@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

@kubaflo , The Gate phase failed due to "ADB0010 / Mono.AndroidTools.InstallFailedException: Unexpected install output: cmd: Failure calling service package: Broken pipe (32).".

@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 24, 2026

🤖 AI Summary

📊 Expand Full Reviewa3f2f52 · replaced android images
🔍 Pre-Flight — Context & Validation

Issue: #10987 - Editor HorizontalTextAlignment Does not Works.
Related Issue: #30052 - [iOS/MacOs] Right-To-Left (RTL) alignment is not applied to Editor placeholder
PR: #25129 - Fixed Editor HorizontalTextAlignment does not update at run time
Platforms Affected: Android (#10987), iOS/macOS (#30052)
Files Changed: 6 implementation, 15 test

Key Findings

  • The PR combines two fixes: Android runtime Editor.HorizontalTextAlignment updates for Editor HorizontalTextAlignment Does not Works. #10987 and iOS/macOS placeholder/runtime alignment behavior for [iOS/MacOs] Right-To-Left (RTL) alignment is not applied to Editor placeholder #30052.
  • Android coverage exists in the PR: Issue10987 host app page, UITest, and Android snapshots were added specifically for runtime alignment changes.
  • Review discussion requested extra RTL coverage, snapshot refreshes, and moving API entries from shipped to unshipped; the current diff reflects those follow-up changes.
  • Unresolved review concerns remain on the iOS/macOS side, including service-release API surface risk around overriding MauiTextView.TextAlignment, a prior macOS test failure, and a later comment that _ => default in ShouldCenterVertically() may be unrelated.
  • Prior agent review content was found in PR comments; it flagged similar concerns but this run is performing a fresh Android-focused gate and try-fix review.

Edge Cases / Reviewer Notes

  • Reviewer requested RTL coverage in the scenario; the added HostApp page now includes both LTR and RTL editors.
  • Snapshot baselines had to be refreshed for macOS and Android because of unrelated screenshot capture changes.
  • PublicAPI entries were previously corrected from Shipped to Unshipped during review.

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #25129 Android: update runtime alignment by setting both TextAlignment and Gravity; iOS/macOS: relayout placeholder and sync placeholder alignment via MauiTextView changes; add UI/device tests and snapshots ⏳ PENDING (Gate) src/Core/src/Platform/Android/TextAlignmentExtensions.cs, src/Core/src/Handlers/Editor/EditorHandler.Android.cs, src/Core/src/Platform/iOS/MauiTextView.cs, src/Core/src/Platform/iOS/TextViewExtensions.cs, tests/snapshots Original PR; Android gate requested, but PR also includes broader iOS/macOS behavior changes

🚦 Gate — Test Verification

Gate Result: ✅ PASSED

Platform: android
Mode: Full Verification

  • Tests FAIL without fix: ✅
  • Tests PASS with fix: ✅

Evidence

  • Verification ran via the required isolated workflow in verify-tests-fail-without-fix.
  • Merge base used for the broken baseline: a1731cfb5ce6f9a53fe0e57a821ec98b76d12767.
  • Six fix files were reverted to merge-base, Issue10987 failed on Android without the fix, then the same files were restored from HEAD and Issue10987 passed.
  • Verification timestamps from verification-log.txt: without-fix run completed at 16:44:14; with-fix run completed at 16:52:57 with expected pass/fail outcomes.

🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) Override EditorHandler.Android.MapHorizontalTextAlignment to supplement runtime TextAlignment updates with explicit Gravity updates only for Editor ✅ PASS src/Core/src/Handlers/Editor/EditorHandler.Android.cs Targeted Android-only alternative; passes Issue10987 but is narrower than the PR because it does not generalize to other EditText-based controls
PR PR #25129 Update shared Android text alignment handling to set both TextAlignment and Gravity; also includes iOS/macOS placeholder/runtime alignment work ✅ PASSED (Gate) src/Core/src/Platform/Android/TextAlignmentExtensions.cs, src/Core/src/Handlers/Editor/EditorHandler.Android.cs, iOS/macOS files, tests/snapshots Gate passed on Android; broader blast radius but likely better cross-control Android coverage

Cross-Pollination

Model Round New Ideas? Details

Exhausted: No
Selected Fix: Pending — 1/4 independent attempts complete.


@MauiBot MauiBot added s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) and removed s/agent-changes-requested AI agent recommends changes - found a better alternative or issues labels Mar 24, 2026
@NirmalKumarYuvaraj
Copy link
Copy Markdown
Contributor Author

@kubaflo , The AI summary is incomplete, can you try again ?

@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Mar 26, 2026

🤖 AI Summary

📊 Expand Full Reviewa3f2f52 · replaced android images
🔍 Pre-Flight — Context & Validation

Issue: #10987 - Editor HorizontalTextAlignment Does not Works.
PR: #25129 - Fixed Editor HorizontalTextAlignment does not update at run time
Platforms Affected: Android, iOS, macOS (Mac Catalyst), Windows
Files Changed: 4 implementation, 2 test (+ snapshots)

Key Findings

  • Android root cause: UpdateHorizontalAlignment used view.TextAlignment = ... (which doesn't update at runtime) OR view.Gravity = ... depending on RTL support, but never both. The fix sets both TextAlignment and Gravity always.
  • iOS/macCatalyst root cause: VerticalTextAlignment was an auto-property with no side effects — changing it didn't re-layout. HorizontalTextAlignment (via UITextView.TextAlignment) was not propagated to the placeholder label. The fix overrides TextAlignment to also update the placeholder label, and converts VerticalTextAlignment to call ShouldCenterVertically() on change.
  • EditorHandler.Android.cs: Minor reordering of Gravity and TextAlignment initialization in CreatePlatformView. PR sets TextAlignment first then Gravity; this ensures initial gravity isn't overwritten by later TextAlignment set (since TextAlignment can reset Gravity).
  • PublicAPI changes: MauiTextView.TextAlignment override is added as public API on net-ios and net-maccatalyst — reviewers (jfversluis) noted concern about adding public API in service release; author responded that they couldn't make it internal since it's an override. These entries are in PublicAPI.Unshipped.txt.
  • Copilot inline suggestion: The ContentOffset change in MauiTextView (line 206) was flagged as potentially unrelated — may affect scrolling behavior.
  • Tests detected: UITest (Issue10987) for UI behavior + DeviceTest (EditorTests.iOS.PlaceholderHorizontalTextAlignment) for iOS-specific device testing.

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #25129 Android: set both TextAlignment+Gravity always; iOS: override TextAlignment to sync placeholder, add setter logic to VerticalTextAlignment ⏳ PENDING (Gate) TextAlignmentExtensions.cs, EditorHandler.Android.cs, MauiTextView.cs, TextViewExtensions.cs Original PR

🚦 Gate — Test Verification

Gate Result: ✅ PASSED

Platform: android

# Type Test Name Filter
1 UITest Issue10987 Issue10987
Step Expected Actual Result
Without fix FAIL FAIL
With fix PASS PASS

Note: verify-tests-fail script reported a false negative (Passed=False Failed=0) but NUnit test runner output confirms Test Run Successful. Total tests: 2, Passed: 2 with the fix applied (UITests/test-output.log at 16:03:45).


🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 claude-opus-4.6 Handler-level: set both TextAlignment+Gravity in MapHorizontalTextAlignment in EditorHandler ✅ PASS 1 file (EditorHandler.Android.cs) Editor-only; doesn't fix Entry/SearchBar
2 claude-sonnet-4.6 Mid-level: fix EditTextExtensions.UpdateHorizontalTextAlignment to also update Gravity when RTL supported ✅ PASS 1 file (EditTextExtensions.cs) Broader: fixes Entry/Editor/SearchBar; minimal change
3 gpt-5.3-codex Platform-view: MauiAppCompatEditText IOnLayoutChangeListener syncs Gravity from TextAlignment on layout ✅ PASS 1 file (MauiAppCompatEditText.cs) Fires on every layout pass — unnecessary overhead
4 gemini-3-pro-preview Platform-view: override TextAlignment property in MauiAppCompatEditText to auto-update Gravity ✅ PASS 2 files (MauiAppCompatEditText.cs, PublicAPI.Unshipped.txt) Clean; requires new public API entry
PR PR #25129 Fix shared UpdateHorizontalAlignment in TextAlignmentExtensions to remove RTL conditional, always set both ✅ PASSED (Gate) 4 files Also fixes iOS/macOS + VerticalTextAlignment; widest scope

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No "Solution space exhausted — all code layers covered"
claude-sonnet-4.6 2 No "Only theoretical variation: drop TextAlignment entirely — degradation, not fix"

Exhausted: Yes
Selected Fix: PR #25129 — The PR's fix is the most complete: it fixes the shared extension used by Editor, Entry, and SearchBar on Android, AND separately fixes iOS/macOS vertical alignment and placeholder horizontal alignment. Candidate 2 is the cleanest Android-only alternative (1 file, broader scope than Attempt 1), but it lacks the iOS/macOS improvements in the PR. The PR's wider scope is appropriate here since the issue affects multiple controls and platforms.


📋 Report — Final Recommendation

✅ Final Recommendation: APPROVE

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #10987 + #30052; Android + iOS/macOS affected; 4 impl files, 2 test files
Gate ✅ PASSED android — both UITests passed (2/2) with fix; FAILED without fix
Try-Fix ✅ COMPLETE 4 attempts, all 4 passing; PR's fix selected as best
Report ✅ COMPLETE

Summary

PR #25129 fixes Editor.HorizontalTextAlignment (and VerticalTextAlignment) not updating at runtime on Android, iOS, and macOS. The Android fix corrects the shared UpdateHorizontalAlignment extension to always set both TextAlignment and Gravity (previously it only set one or the other based on RTL support). The iOS/macOS fix overrides TextAlignment in MauiTextView to propagate changes to the placeholder label, and converts VerticalTextAlignment from an auto-property to a property with side effects that triggers ShouldCenterVertically(). Tests confirm the bug is detected without the fix and resolved with it.

Root Cause

On Android, EditText.TextAlignment alone does not trigger a visual re-render at runtime — Gravity must also be set. The old code had an RTL-conditional that set one OR the other, never both, so runtime changes to alignment were silently ignored. On iOS/macOS, the VerticalTextAlignment property was a simple auto-property (no side effects), and the placeholder label was never updated when TextAlignment changed on UITextView.

Fix Quality

  • Android fix is correct and minimal. Always setting both TextAlignment and Gravity is safe (they are complementary; Gravity does the visual work, TextAlignment provides semantic BiDi meaning). The try-fix exploration confirmed this is the right location in the call stack.
  • iOS/macOS fix adds a TextAlignment property override in MauiTextView (public API addition noted in PublicAPI.Unshipped.txt) and makes VerticalTextAlignment reactive. A reviewer (jfversluis) raised concern about new public API in a service release; the author responded that the override couldn't be made internal since it overrides a UIKit property. This is a legitimate concern worth flagging.
  • Copilot inline suggestion flagged a change from ContentOffset to default in MauiTextView.cs line ~206 as potentially unrelated — this should be reviewed.
  • Tests use VerifyScreenshot() with snapshot baselines for Android/iOS/macOS/Windows. The EditorRuntimeTextAlignmentChanged test contains an #if IOS block (uses KeyboardScrolling.HideKeyboard) — acceptable here as it's isolating a platform-specific keyboard interaction.
  • Alternative candidate (Attempt 2): Fixing EditTextExtensions.UpdateHorizontalTextAlignment in 1 file would be a cleaner Android-only fix, but the PR also addresses iOS/macOS which is more complete.

Concerns

  1. Public API addition (MauiTextView.TextAlignment override): public override UITextAlignment TextAlignment is added to PublicAPI.Unshipped.txt. For a service release this is unusual but is technically required for an override. Low risk.
  2. Unrelated ContentOffset change in MauiTextView.cs: Copilot flagged this as potentially affecting scrolling behavior. Should be confirmed as intentional or reverted.
  3. Snapshot tests: The PR updates multiple snapshot baselines (Android, iOS, macOS, Windows). These need to match the CI environment precisely. Historical CI failures were seen during review (size mismatches) that were resolved.

@MauiBot MauiBot added s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) s/agent-fix-win AI found a better alternative fix than the PR labels Mar 26, 2026
@kubaflo kubaflo changed the base branch from main to inflight/current March 26, 2026 23:09
@kubaflo kubaflo merged commit cd955c5 into dotnet:inflight/current Mar 26, 2026
28 of 31 checks passed
@github-project-automation github-project-automation bot moved this from Changes Requested to Done in MAUI SDK Ongoing Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-editor Editor community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios s/agent-approved AI agent recommends approval - PR fix is correct and optimal s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[iOS/MacOs] Right-To-Left (RTL) alignment is not applied to Editor placeholder Editor HorizontalTextAlignment Does not Works.

8 participants