Skip to content

Conversation

@SuthiYuvaraj
Copy link
Contributor

@SuthiYuvaraj SuthiYuvaraj commented Oct 10, 2024

RootCause

In the case of a rounded rectangle, the stroke thickness is added to the measured size during each Measure call. As a result, for every input in the Entry control, the width and height of the rounded rectangle are updated.

This issue was introduced due to the following PRs:
Rendering Shapes without explicit bounds. by VSadov · Pull Request #5817 · dotnet/maui (github.com)
Fixed Android RoundRectangle border logic by jstedfast · Pull Request #17087 · dotnet/maui (github.com)

While reverting change in above PR, current fix is fixed and issue mentioned above PR replicates.

Description of Change

The fix ensures that RoundRectangle handles stroke thickness consistently across measure calls. Previously, GetPath() directly used the full width and height without adjusting for StrokeThickness, causing the measured size to increase with each input event.

To resolve this, GetInnerPath() has been updated to exclude StrokeThickness from the size calculation, aligning RoundRectangle behavior with Rectangle. This prevents the height from increasing on each MeasureOverride() call.

Issues Fixed

Fixes #18092

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output Videos

Before Issue Fix After Issue Fix
18092_BeforeCahnges.mp4
18092_AfterChanges.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 10, 2024
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@SuthiYuvaraj SuthiYuvaraj marked this pull request as ready for review October 15, 2024 06:27
@SuthiYuvaraj SuthiYuvaraj requested a review from a team as a code owner October 15, 2024 06:27
@SuthiYuvaraj SuthiYuvaraj marked this pull request as draft October 16, 2024 11:16
@jsuarezruiz jsuarezruiz added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Oct 17, 2024
@SuthiYuvaraj SuthiYuvaraj marked this pull request as ready for review October 18, 2024 07:58
@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

/rebase

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Oct 25, 2024

/azp run

@azure-pipelines

This comment was marked as outdated.

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 9 Servicing milestone Oct 31, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
// TODO: not using this.GetPath().Bounds.Size;
// since default GetBoundsByFlattening(0.001) returns incorrect results for curves
RectF pathBounds = this.GetPath().GetBoundsByFlattening(1);
// Get the inner path by subtracting the stroke thickness for a rounded rectangle, as the GetPath() method returns the path including the stroke thickness.
Copy link
Contributor

Choose a reason for hiding this comment

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

A better approach would be to align the behavior between the RoundRectangle and the rest of the shapes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz @PureWeen, The issue occurs specifically with RoundRectangle because its GetPath() method does not exclude StrokeThickness from width and height calculations. In contrast, other shapes like Rectangle and Ellipse already account for StrokeThickness in their GetPath() implementations.

For example, in Rectangle.cs, GetPath() subtracts StrokeThickness from both width and height before creating the path. However, in RoundRectangle.cs, GetPath() directly uses the full width and height without adjusting for StrokeThickness.

As a result, each MeasureOverride() call includes StrokeThickness in the size calculation, causing the height to increase on every input event for RoundRectangle. To align behavior across all shapes, I have updated the RoundRectangle implementation to exclude StrokeThickness from GetInnerPath(), ensuring consistency with Rectangle.cs.

Copy link
Member

Choose a reason for hiding this comment

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

What would happen if we just aligned the GetPath method of RoundRectangle to work like the GetPath of Rectangle and Ellipse?

The worry here is that we're creating an extra method that's purely for a special case scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PureWeen The GetPath method of RoundRectangle was intentionally modified in a previous PR to remove any compensation for StrokeThickness, as the calling code now handles that separately. The PR description explicitly states that GetPath should use the width and height as-is, without adjustments for StrokeThickness.
To maintain consistency with the updated approach while still resolving the issue, I have applied the fix within GetInnerPath. This ensures that the behavior aligns with other shapes without altering GetPath, which has already been adjusted for a broader set of changes.

Copy link
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.

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

Could we align the behavior between all the shapes? #25166 (comment)

@sheiksyedm
Copy link
Contributor

Could we align the behavior between all the shapes? #25166 (comment)

reply : #25166 (comment)

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

@SuthiYuvaraj Could you rebase? Thanks in advance.

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@StephaneDelcroix StephaneDelcroix changed the base branch from main to inflight/current December 3, 2025 17:00
@StephaneDelcroix StephaneDelcroix merged commit 2cc27d8 into dotnet:inflight/current Dec 3, 2025
126 of 129 checks passed
@github-project-automation github-project-automation bot moved this from Changes Requested to Done in MAUI SDK Ongoing Dec 3, 2025
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…#25166)

* Fix commit for 18092

* Update Shape.cs

* Commit for Maccatalyst

* Update Shape.cs

* Update Shape.cs

* Commit for RoundRectangle change

* commit name changes

* Update Issue18092.xaml

* Update Issue18092.xaml

* Update Issue18092.xaml

* Commit for method name
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…#25166)

* Fix commit for 18092

* Update Shape.cs

* Commit for Maccatalyst

* Update Shape.cs

* Update Shape.cs

* Commit for RoundRectangle change

* commit name changes

* Update Issue18092.xaml

* Update Issue18092.xaml

* Update Issue18092.xaml

* Commit for method name
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…#25166)

* Fix commit for 18092

* Update Shape.cs

* Commit for Maccatalyst

* Update Shape.cs

* Update Shape.cs

* Commit for RoundRectangle change

* commit name changes

* Update Issue18092.xaml

* Update Issue18092.xaml

* Update Issue18092.xaml

* Commit for method name
github-actions bot pushed a commit that referenced this pull request Dec 5, 2025
…#25166)

* Fix commit for 18092

* Update Shape.cs

* Commit for Maccatalyst

* Update Shape.cs

* Update Shape.cs

* Commit for RoundRectangle change

* commit name changes

* Update Issue18092.xaml

* Update Issue18092.xaml

* Update Issue18092.xaml

* Commit for method name
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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[regression/8.0.0] Entry bug—height grows on every input event

5 participants