-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix Path Rendering Issue Inside StackLayout When Margin Is Set #28071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e3a7872
Fixed the path does not consider a margin issue
Shalini-Ashokan 3344c4d
Added test cases
Shalini-Ashokan f6eedb5
Committed the images
Shalini-Ashokan 45bd24b
Modified the logics
Shalini-Ashokan 935f45b
committed the images
Shalini-Ashokan 69ea417
Modified the images
Shalini-Ashokan e07023f
Committed the images
Shalini-Ashokan 59572e9
Added line and polyline to test case sample
Shalini-Ashokan 6e4253d
Remove ios image
Shalini-Ashokan d05f63f
Committed the images
Shalini-Ashokan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+35.2 KB
.../tests/TestCases.Android.Tests/snapshots/android/Issue13801VerifyPathMargin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue13801"> | ||
|
|
||
| <StackLayout VerticalOptions="Start"> | ||
| <Label AutomationId="PathLabel" | ||
| Text="Path with Margin"/> | ||
| <Path Stroke="Red" | ||
| StrokeThickness="5" | ||
| Data="M 0 0 L 100 0 L 100 100 L 0 100 Z" | ||
| Margin="20"/> | ||
| <Path Stroke="Blue" | ||
| StrokeThickness="5" | ||
| Data="M 0 0 L 100 0 L 100 100 L 0 100 Z" | ||
| Margin="-10"/> | ||
| <Label Text="Polyline with Margin" | ||
| Margin="0,15,0,0"/> | ||
| <Polyline Stroke="Purple" | ||
| StrokeThickness="5" | ||
| Points="10,10 40,25 70,10 70,40 40,55 10,40 10,10" | ||
| Margin="20" | ||
| HorizontalOptions="Start"/> | ||
| <Polyline Stroke="Pink" | ||
| StrokeThickness="5" | ||
| Points="10,10 40,25 70,10 70,40 40,55 10,40 10,10" | ||
| Margin="-10" | ||
| HorizontalOptions="Start"/> | ||
| <Label Text="Line with Margin" | ||
| Margin="0,15,0,0"/> | ||
| <Line Stroke="Green" | ||
| StrokeThickness="5" | ||
| X1="0" | ||
| Y1="0" | ||
| X2="100" | ||
| Y2="50" | ||
| Margin="20"/> | ||
| <Line Stroke="Orange" | ||
| StrokeThickness="5" | ||
| X1="0" | ||
| Y1="0" | ||
| X2="100" | ||
| Y2="50" | ||
| Margin="-10"/> | ||
| </StackLayout> | ||
| </ContentPage> |
11 changes: 11 additions & 0 deletions
11
src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [Issue(IssueTracker.Github, 13801, "Path does not render if it has Margin", PlatformAffected.All)] | ||
| public partial class Issue13801 : ContentPage | ||
| { | ||
| public Issue13801() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } | ||
| } |
Binary file added
BIN
+18.4 KB
...Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue13801VerifyPathMargin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue13801.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue13801 : _IssuesUITest | ||
| { | ||
| public override string Issue => "Path does not render if it has Margin"; | ||
|
|
||
| public Issue13801(TestDevice testDevice) : base(testDevice) { } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Shape)] | ||
| public void Issue13801VerifyPathMargin() | ||
| { | ||
| App.WaitForElement("PathLabel"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| } |
Binary file added
BIN
+10.4 KB
...ls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue13801VerifyPathMargin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.9 KB
...Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue13801VerifyPathMargin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is required for Line, PolyLine and Path and not for example for Polyline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz, In non-closed shapes such as Line, Polyline, and Path, the margin is not considered when the shape is inside a StackLayout and no explicit size is defined. The base size value is returned before measuring the path size because the measured result includes the margin, causing the shape to be invisible.
When the height or width is not explicitly set for these shapes, the shape size is reset using boundsByFlattening and does not account for the margin. Hence, the margin is now added at the end of non-closed shapes