Skip to content

Fixed FlowDirection property not working on Drawable control and GraphicsView#34557

Open
Dhivya-SF4094 wants to merge 4 commits intodotnet:mainfrom
Dhivya-SF4094:Fix_34402
Open

Fixed FlowDirection property not working on Drawable control and GraphicsView#34557
Dhivya-SF4094 wants to merge 4 commits intodotnet:mainfrom
Dhivya-SF4094:Fix_34402

Conversation

@Dhivya-SF4094
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

The FlowDirection property is not functioning as expected when applied to Drawable controls and GraphicsView.
When FlowDirection is set to either RightToLeft or LeftToRight, there is no observable change in layout behavior.

Root Cause

ShapeViewHandler had no FlowDirection mapper, and ShapeDrawable.Draw() never applied canvas mirroring.

Description of Change

Android: Updated PlatformGraphicsView to mirror its content horizontally when the layout direction is RTL by applying a translation and scale transformation in the Draw method.
iOS: Modified PlatformGraphicsView to check EffectiveUserInterfaceLayoutDirection and apply a horizontal flip transformation when in RTL mode.
Windows: Changed PlatformGraphicsView to concatenate a scale and translation transform for RTL flow direction before drawing content.

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed:

Fixes #34402

Screenshots

Before  After 
 
34402_BeforeChange.mov
  
34402_AfterChanges.mov

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

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

Or

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

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Mar 19, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review March 19, 2026 10:36
Copilot AI review requested due to automatic review settings March 19, 2026 10:36
@sheiksyedm sheiksyedm added platform/windows platform/android area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/ios community ✨ Community Contribution labels Mar 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes FlowDirection support for Shape-based drawables (e.g., BoxView/ShapeView) and GraphicsView by ensuring RTL flow direction results in a mirrored drawing surface across Android/iOS/Windows, and adds UI test coverage for issue #34402.

Changes:

  • Mirror PlatformGraphicsView drawing output in RTL mode on Android, iOS, and Windows.
  • Add FlowDirection mapping to ShapeViewHandler so shape-backed controls react to FlowDirection changes.
  • Add a HostApp repro page + Appium screenshot tests (and snapshots) for issue #34402.

Reviewed changes

Copilot reviewed 7 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Graphics/src/Graphics/Platforms/Android/PlatformGraphicsView.cs Mirrors the Android canvas in RTL by translating + scaling before drawing.
src/Graphics/src/Graphics/Platforms/iOS/PlatformGraphicsView.cs Mirrors the CoreGraphics context in RTL using TranslateCTM + ScaleCTM, scoped with save/restore.
src/Graphics/src/Graphics/Platforms/Windows/PlatformGraphicsView.cs Applies a Win2D transform (scale + translation) in RTL before drawing.
src/Core/src/Handlers/ShapeView/ShapeViewHandler.cs Adds a FlowDirection mapper to ensure shape views update and invalidate when flow direction changes.
src/Core/src/Handlers/ShapeView/ShapeViewHandler.Standard.cs Adds the corresponding stub mapper for non-platform builds.
src/Controls/tests/TestCases.HostApp/Issues/Issue34402.cs Adds a HostApp page to reproduce and visually validate LTR↔RTL mirroring for BoxView and GraphicsView.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34402.cs Adds Appium tests that validate the mirroring via screenshot baselines.
src/Controls/tests/TestCases.Android.Tests/snapshots/android/GraphicsView_RTL_AfterButton.png Adds/updates an Android screenshot baseline for the new test.

@sheiksyedm
Copy link
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues 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) s/agent-fix-win AI found a better alternative fix than the PR and removed s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates labels Mar 20, 2026
Copy link
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

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

Could you please look at the AI's summary?

@Dhivya-SF4094
Copy link
Contributor Author

Could you please look at the AI's summary?

The gate failure on Android appears to be environment-related — one leg was blocked by an ADB0010 broken pipe error (infra issue, not a test failure), and the secondary ~2.08% GraphicsViewFlowDirectionShouldMirrorOnRTL screenshot drift is consistent with emulator rendering noise; the test passes consistently in local runs.

@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
@sheiksyedm
Copy link
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues and removed s/agent-review-incomplete AI agent could not complete all phases (blocker, timeout, error) labels Mar 26, 2026
@dotnet dotnet deleted a comment from MauiBot Mar 26, 2026
@MauiBot
Copy link
Collaborator

MauiBot commented Mar 27, 2026

🤖 AI Summary

📊 Expand Full Review395c181 · Add snapshots for iOS 26 and resaved images for failed case
🔍 Pre-Flight — Context & Validation

Issue: #34402 - [Android, Windows, iOS, macOS] FlowDirection property not working on BoxView Control
PR: #34557 - Fixed FlowDirection property not working on Drawable control and GraphicsView
Platforms Affected: Android, iOS, Windows, macOS
Files Changed: 4 implementation, 2 test (+ snapshot images)

Key Findings

  • ShapeViewHandler had no FlowDirection mapper, so changes to FlowDirection never triggered a redraw/update on any platform
  • PlatformGraphicsView.Draw() on all platforms never applied canvas mirroring for RTL, so drawable content was always drawn LTR
  • Fix adds FlowDirection mapper to ShapeViewHandler and applies canvas mirroring in Draw() on Android, iOS, and Windows
  • Android: Checks LayoutDirection == ALayoutDirection.Rtl in Draw(), applies Translate(Width, 0) + Scale(-1, 1), refactors drawing into DrawContent() helper
  • iOS: Checks EffectiveUserInterfaceLayoutDirection == RightToLeft, applies TranslateCTM + ScaleCTM(-1, 1), similar DrawContent() helper
  • Windows: Checks FlowDirection == FlowDirection.RightToLeft, concatenates Matrix3x2.CreateScale(-1, 1) * CreateTranslation(width, 0)
  • Copilot review noted: Windows comparison uses global::Microsoft.UI.Xaml.FlowDirection.RightToLeft (already fixed by PR author per inline comment)
  • Copilot review noted: Initial FlowDirection in HostApp set to LeftToRight explicitly — adequate
  • Copilot review noted: Missing WinUI snapshots for new tests (PR author acknowledged, will add in next CI)
  • MapFlowDirection is marked internal with a TODO to make public in .NET 11 (public API change is a breaking change concern)
  • Inconsistent indentation in MapFlowDirection body in ShapeViewHandler.cs (mixed tabs/spaces)
  • Missing newline at end of ShapeViewHandler.cs

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #34557 Add FlowDirection mapper to ShapeViewHandler + apply canvas mirroring in PlatformGraphicsView.Draw() on each platform ⏳ PENDING (Gate) ShapeViewHandler.cs, ShapeViewHandler.Standard.cs, PlatformGraphicsView.cs (Android/iOS/Windows) Original PR

🚦 Gate — Test Verification

Gate Result: ❌ FAILED

Platform: android

# Type Test Name Filter
1 UITest Issue34402 Issue34402
Step Expected Actual Result
Without fix FAIL FAIL (ADB0010 infrastructure error — package manager unavailable, NUnit never ran)
With fix PASS PARTIAL — BoxViewFlowDirectionShouldMirrorOnRTL ✅, GraphicsViewFlowDirectionShouldMirrorOnRTL ❌ (2.08% baseline mismatch on GraphicsView_LTR_Initial.png)

🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix Inline Save/Restore in Draw() with LayoutDirection == Rtl check, no DrawContent() extraction; same ShapeViewHandler mapper as PR ✅ PASS 3 files Both tests pass individually; functionally equivalent to PR but smaller diff
2 try-fix Explicit IsRtl bool property on PlatformGraphicsView, set from handler mapper ❌ FAIL 5+ files Bool property causes pixel-level baseline mismatch vs LayoutDirection-based check
3 try-fix Matrix concat (SetScale(-1,1) + PostTranslate(Width,0)) with LayoutDirection == Rtl ❌ FAIL 3 files 2.08% GraphicsView_LTR_Initial mismatch — matrix pixel output differs from direct Translate/Scale
4 try-fix Override OnRtlPropertiesChanged in PlatformGraphicsView to trigger Invalidate, mapper only calls UpdateFlowDirection ❌ FAIL 3 files RS0016 public API violation — adding public override requires PublicAPI.Unshipped.txt update
PR PR #34557 DrawContent() extraction + try/finally + LayoutDirection == Rtl check + UpdateFlowDirection + InvalidateShape in mapper ✅ PASSED (Gate) 5 files Original PR — cleanest structure, passes tests

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No "NO NEW IDEAS — attempts are exhaustive. PR's DrawContent() extraction is cleanest."
gpt-5.3-codex 2 No "NO NEW IDEAS"

Exhausted: Yes
Selected Fix: PR #34557 — DrawContent() extraction is cleaner and more readable than Attempt 1's inline approach. Both are functionally equivalent; PR's version is the better production code.


📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #34402, FlowDirection on BoxView/GraphicsView, all platforms
Gate ❌ FAILED Android — BoxView test ✅, GraphicsView_LTR_Initial 2.08% baseline mismatch
Try-Fix ✅ COMPLETE 4 attempts, 1 passing (Attempt 1 functionally equivalent to PR)
Report ✅ COMPLETE

Summary

PR #34557 fixes a real bug — FlowDirection had no effect on BoxView/GraphicsView across all platforms. The implementation approach (canvas mirroring in PlatformGraphicsView.Draw() + ShapeViewHandler FlowDirection mapper) is correct and aligns with how other MAUI platform views handle RTL. However, the GraphicsViewFlowDirectionShouldMirrorOnRTL test fails in CI with a 2.08% screenshot baseline mismatch on GraphicsView_LTR_Initial.png. This is a test quality issue (test state contamination across shared page + baseline needs refresh), not a logic defect. Additionally, code quality issues need addressing before merge.

Root Cause

ShapeViewHandler lacked a FlowDirection property mapper, so FlowDirection changes never propagated to the platform view or triggered a redraw. PlatformGraphicsView.Draw() also never applied canvas mirroring. The fix correctly adds both pieces.

Fix Quality

The fix logic is sound. However, the following issues need resolution:

  1. Failing test baseline (GraphicsView_LTR_Initial.png): The GraphicsViewFlowDirectionShouldMirrorOnRTL test fails in CI with 2.08% difference. The baseline needs to be regenerated from CI (not from a local machine). The author's explanation of "emulator rendering noise" may be partially correct but the fix is to regenerate or add tolerance: 2.1 to this specific screenshot.

  2. Missing WinUI snapshot baselines: As flagged by Copilot reviewer, TestCases.WinUI.Tests/snapshots/windows/ is missing BoxView_LTR_Initial.png, BoxView_RTL_AfterButton.png, GraphicsView_LTR_Initial.png, GraphicsView_RTL_AfterButton.png. WinUI tests will fail until these are added.

  3. Mixed indentation in ShapeViewHandler.cs: The MapFlowDirection method body has inconsistent mixed tab/space indentation — should use tabs consistently with the surrounding code.

  4. Missing newline at end of ShapeViewHandler.cs: File is missing EOF newline (diff shows \ No newline at end of file).

  5. internal visibility on MapFlowDirection: Marked internal with a TODO for .NET 11. This is acceptable as a conscious design decision but the TODO should reference a tracking issue.

  6. MapFlowDirection is identical across PR and Attempt 1: Both passing approaches have the exact same ShapeViewHandler change — the architectural decision here is sound and validated.

Verdict

The fix is architecturally correct and should be approved once:

  • GraphicsView_LTR_Initial.png baseline is regenerated from CI (or tolerance added)
  • WinUI snapshot baselines are added
  • Indentation and EOF newline in ShapeViewHandler.cs are fixed

@MauiBot MauiBot added s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-fix-win AI found a better alternative fix than the PR labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios platform/windows s/agent-changes-requested AI agent recommends changes - found a better alternative or issues 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

None yet

Development

Successfully merging this pull request may close these issues.

[Android, Windows, iOS, macOS] FlowDirection property not working on BoxView Control

6 participants