-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed Rectangle renders as thin line instead of filled shape for small height #31651
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| using Microsoft.Maui.Controls.Shapes; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 31330, "Rectangle renders as thin line instead of filled shape for small height values", PlatformAffected.Android | PlatformAffected.iOS)] | ||
| public class Issue31330 : ContentPage | ||
| { | ||
| public Issue31330() | ||
| { | ||
| var scrollView = new ScrollView | ||
| { | ||
| Orientation = ScrollOrientation.Both, | ||
| VerticalScrollBarVisibility = ScrollBarVisibility.Always, | ||
| HorizontalScrollBarVisibility = ScrollBarVisibility.Always, | ||
| }; | ||
|
|
||
| var grid = new Grid | ||
| { | ||
| WidthRequest = 800, | ||
| HeightRequest = 600, | ||
| BackgroundColor = Colors.LightGray, | ||
| RowSpacing = 10, | ||
| Padding = 20 | ||
| }; | ||
|
|
||
| grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
| grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
| grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); | ||
| grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star }); | ||
|
|
||
| // Instructions | ||
| var instructions = new Label | ||
| { | ||
| Text = "Test passes if:\n1. Red BoxView (height 1.2) is visible as a filled rectangle\n2. Blue Rectangle (height 1.2) is visible as a filled rectangle (not a thin line)\n3. Both should have similar appearance", | ||
| FontAttributes = FontAttributes.Bold, | ||
| AutomationId = "Instructions" | ||
| }; | ||
| Grid.SetRow(instructions, 0); | ||
| grid.Children.Add(instructions); | ||
|
|
||
| // BoxView with small height (reference for correct rendering) | ||
| var boxViewLabel = new Label { Text = "BoxView (height 1.2):" }; | ||
| Grid.SetRow(boxViewLabel, 1); | ||
| grid.Children.Add(boxViewLabel); | ||
|
|
||
| var boxView = new BoxView | ||
| { | ||
| Color = Colors.Red, | ||
| WidthRequest = 50, | ||
| HeightRequest = 1.2, | ||
| HorizontalOptions = LayoutOptions.Start, | ||
| VerticalOptions = LayoutOptions.Start, | ||
| AutomationId = "TestBoxView" | ||
| }; | ||
| Grid.SetRow(boxView, 1); | ||
| grid.Children.Add(boxView); | ||
|
|
||
| // Rectangle with small height (should render like BoxView, not as a line) | ||
| var rectangleLabel = new Label { Text = "Rectangle (height 1.2, Fill only, no Stroke):" }; | ||
| Grid.SetRow(rectangleLabel, 2); | ||
| grid.Children.Add(rectangleLabel); | ||
|
|
||
| var rectangle = new Rectangle | ||
| { | ||
| WidthRequest = 50, | ||
| HeightRequest = 1.2, | ||
| Fill = Colors.Blue, | ||
| Stroke = null, // Explicitly no stroke | ||
| HorizontalOptions = LayoutOptions.Start, | ||
| VerticalOptions = LayoutOptions.Start, | ||
| AutomationId = "TestRectangle" | ||
| }; | ||
| Grid.SetRow(rectangle, 2); | ||
| grid.Children.Add(rectangle); | ||
|
|
||
| // AbsoluteLayout test (from original issue report) | ||
| var absoluteLayout = new AbsoluteLayout | ||
| { | ||
| BackgroundColor = Colors.White, | ||
| AutomationId = "AbsoluteLayoutTest" | ||
| }; | ||
| Grid.SetRow(absoluteLayout, 3); | ||
| grid.Children.Add(absoluteLayout); | ||
|
|
||
| double shapeWidth = 20; | ||
| double shapeHeight = 1.2; | ||
| double centerX = 400; | ||
| double centerY = 200; | ||
|
|
||
| // BoxView in AbsoluteLayout (reference) | ||
| var absBoxView = new BoxView | ||
| { | ||
| BackgroundColor = Colors.Red | ||
| }; | ||
| AbsoluteLayout.SetLayoutBounds(absBoxView, new Rect( | ||
| centerX - shapeWidth - 30, | ||
| centerY - (shapeHeight / 2), | ||
| shapeWidth, | ||
| shapeHeight | ||
| )); | ||
| AbsoluteLayout.SetLayoutFlags(absBoxView, AbsoluteLayoutFlags.None); | ||
|
Check failure on line 101 in src/Controls/tests/TestCases.HostApp/Issues/Issue31330.cs
|
||
| absoluteLayout.Children.Add(absBoxView); | ||
|
|
||
| // Rectangle in AbsoluteLayout (should match BoxView appearance) | ||
| var absRectangle = new Rectangle | ||
| { | ||
| Fill = Colors.Blue | ||
| }; | ||
| AbsoluteLayout.SetLayoutBounds(absRectangle, new Rect( | ||
| centerX + 30, | ||
| centerY - (shapeHeight / 2), | ||
| shapeWidth, | ||
| shapeHeight | ||
| )); | ||
| AbsoluteLayout.SetLayoutFlags(absRectangle, AbsoluteLayoutFlags.None); | ||
|
Check failure on line 115 in src/Controls/tests/TestCases.HostApp/Issues/Issue31330.cs
|
||
| absoluteLayout.Children.Add(absRectangle); | ||
|
|
||
| scrollView.Content = grid; | ||
| Content = scrollView; | ||
| } | ||
| } | ||
| 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 Issue31330 : _IssuesUITest | ||
| { | ||
| public Issue31330(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
| public override string Issue => "Rectangle renders as thin line instead of filled shape for small height values"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Shape)] | ||
| public void UpdateSizeOnlyWhenStrokeExists() | ||
| { | ||
| App.WaitForElement("Issue31330BoxView"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
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.
Running a build, pending snapshot on some platforms.
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.
Test failing on Windows:
Uh oh!
There was an error while loading. Please reload this page.
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.
Pending snapshot on Mac:

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, Added pending snapshots for Android, Mac, and Windows platforms. Re-saved images for failed cases due to recent changes related to shapes.