-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Fixed Setting a Label visible after having had focus on a InputView will increase the Label's height #29210
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
Changes from 6 commits
ae6b47d
44390c8
2f60649
4cca0a3
4fba867
1819210
58f977c
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,37 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 29194, "[Android][Label] Setting a Label visible after having had focus on a InputView will increase the Label's height", PlatformAffected.Android)] | ||
| public class Issue29194 : ContentPage | ||
| { | ||
| public Issue29194() | ||
| { | ||
| var mySwitch = new Switch() { AutomationId = "Switch" }; | ||
|
|
||
| var label = new Label | ||
| { | ||
| Text = "Hello, World!", | ||
| BackgroundColor = Colors.Red, | ||
| AutomationId = "Label" | ||
| }; | ||
|
|
||
| label.SetBinding(Label.IsVisibleProperty, new Binding(nameof(Switch.IsToggled), source: mySwitch)); | ||
|
|
||
| var verticalStack = new VerticalStackLayout | ||
| { | ||
| Children = | ||
| { | ||
| label, | ||
| mySwitch, | ||
| new UITestEntry() {AutomationId = "Entry",IsCursorVisible=false}, | ||
| } | ||
| }; | ||
|
|
||
| var scrollView = new ScrollView | ||
| { | ||
| Content = verticalStack | ||
| }; | ||
|
|
||
| Content = scrollView; | ||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
| public class Issue29194 : _IssuesUITest | ||
| { | ||
| public Issue29194(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "[Android][Label] Setting a Label visible after having had focus on a InputView will increase the Label's height"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Label)] | ||
| public void LabelShouldSizeProperly() | ||
| { | ||
| App.WaitForElement("Entry"); | ||
| App.Tap("Entry"); | ||
| App.Tap("Switch"); | ||
| App.WaitForElement("Label"); | ||
| App.DismissKeyboard(); | ||
| VerifyScreenshot(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,12 @@ protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) | |
| { | ||
| if (MeasureSpec.GetMode(widthMeasureSpec) == MeasureSpecMode.AtMost && Layout is not null) | ||
| { | ||
| int maxWidth = (int)Math.Ceiling(GetMaxLineWidth(Layout)) + CompoundPaddingLeft + CompoundPaddingRight; | ||
| widthMeasureSpec = MeasureSpec.MakeMeasureSpec(maxWidth, MeasureSpecMode.AtMost); | ||
| // Ensure the Layout is valid and measured before reading LineCount or GetLineWidth(i) to avoid unnecessary calculations. | ||
| if (Layout.Width > 0) | ||
jsuarezruiz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| int maxWidth = (int)Math.Ceiling(GetMaxLineWidth(Layout)) + CompoundPaddingLeft + CompoundPaddingRight; | ||
|
||
| widthMeasureSpec = MeasureSpec.MakeMeasureSpec(maxWidth, MeasureSpecMode.AtMost); | ||
| } | ||
| } | ||
| base.OnMeasure(widthMeasureSpec, heightMeasureSpec); | ||
| } | ||
|
|
||
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.
This test could potentially fail. Must use the
UITestEntryfrom the test controls and theIsCursorVisibleproperty to false.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.
I modified the test sample to use
UITestEntryand setIsCursorVisibleto false to avoid cursor-related issues in the future. @jsuarezruiz