-
Notifications
You must be signed in to change notification settings - Fork 2k
[Android] Fix CollectionView selection crash with HeaderTemplate #34275
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 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2f22928
[ci] Auto-trigger uitests and device-tests on darc-* branches (#34317)
PureWeen 2c6474f
Add PublicAPI.Unshipped.txt BOM sort warning to Copilot instructions …
jfversluis 3e2acb4
[Android] Fix crash in GraphicsView when using TapGestureRecognizer (…
jpd21122012 538463e
[Android] Fix Label with MaxLines truncating text in horizontal Scrol…
Vignesh-SF3580 adb4bef
fix 34247
NirmalKumarYuvaraj 18f6a04
addressed AI summary
NirmalKumarYuvaraj 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
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
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ trigger: | |
| - release/* | ||
| - net*.0 | ||
| - inflight/* | ||
| - darc-* | ||
| tags: | ||
| include: | ||
| - '*' | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ trigger: | |
| - release/* | ||
| - net*.0 | ||
| - inflight/* | ||
| - darc-* | ||
| tags: | ||
| include: | ||
| - '*' | ||
|
|
||
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
+296 KB
...sts/TestCases.Android.Tests/snapshots/android/LabelNotTruncatedWithMaxLines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,81 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 34120, "Label text truncated in ScrollView when MaxLines is set", PlatformAffected.Android)] | ||
| public class Issue34120 : ContentPage | ||
| { | ||
| // Reproduces the N3_Navigation layout: horizontal ScrollView with BindableLayout, | ||
| // 200×200 Border cards, Image (HeightRequest=120), and a Label with MaxLines=2. | ||
| record Issue34120MonkeyItem(string Name, string ImageUrl); | ||
|
|
||
| public Issue34120() | ||
| { | ||
| // Long names ("Golden Snub-nosed Monkey", "Tonkin Snub-nosed Monkey") are the ones | ||
| // that triggered truncation; "Baboon" is a short-name reference card. | ||
| var monkeys = new List<Issue34120MonkeyItem> | ||
| { | ||
| new("Golden Snub-nosed Monkey", "golden.jpg"), | ||
| new("Baboon", "papio.jpg"), | ||
| new("Tonkin Snub-nosed Monkey", "bluemonkey.jpg"), | ||
| new("Howler Monkey", "alouatta.jpg"), | ||
| new("Squirrel Monkey", "saimiri.jpg"), | ||
| }; | ||
|
|
||
| var itemTemplate = new DataTemplate(() => | ||
| { | ||
| var image = new Image | ||
| { | ||
| Aspect = Aspect.AspectFit, | ||
| HeightRequest = 120, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| }; | ||
| image.SetBinding(Image.SourceProperty, "ImageUrl"); | ||
|
|
||
| var nameLabel = new Label | ||
| { | ||
| FontSize = 14, | ||
| FontAttributes = FontAttributes.Bold, | ||
| BackgroundColor = Color.FromArgb("#AAFFFFFF"), | ||
| TextColor = Colors.Black, | ||
| Padding = new Thickness(4, 2), | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| HorizontalTextAlignment = TextAlignment.Center, | ||
| LineBreakMode = LineBreakMode.WordWrap, | ||
| MaxLines = 2, | ||
| }; | ||
| nameLabel.SetBinding(Label.TextProperty, "Name"); | ||
| nameLabel.SetBinding(Label.AutomationIdProperty, "Name"); | ||
|
|
||
| var card = new Border | ||
| { | ||
| Padding = new Thickness(10), | ||
| Stroke = Colors.LightGray, | ||
| StrokeThickness = 1, | ||
| WidthRequest = 200, | ||
| HeightRequest = 200, | ||
| BackgroundColor = Colors.White, | ||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 10, | ||
| Children = { image, nameLabel } | ||
| } | ||
| }; | ||
| return card; | ||
| }); | ||
|
|
||
| var horizontalStack = new HorizontalStackLayout | ||
| { | ||
| Spacing = 15, | ||
| Padding = new Thickness(5), | ||
| }; | ||
| BindableLayout.SetItemTemplate(horizontalStack, itemTemplate); | ||
| BindableLayout.SetItemsSource(horizontalStack, monkeys); | ||
|
|
||
| Content = new ScrollView | ||
| { | ||
| Orientation = ScrollOrientation.Horizontal, | ||
| Content = horizontalStack, | ||
| }; | ||
| } | ||
| } |
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,58 @@ | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 34247, "CollectionView with HeaderTemplate and SelectionMode.Single crashes on selection", PlatformAffected.All)] | ||
| public class Issue34247 : ContentPage | ||
| { | ||
| public Issue34247() | ||
| { | ||
| var layout = new StackLayout(); | ||
|
|
||
| var resultLabel = new Label() | ||
| { | ||
| Text = "Select an item to test", | ||
| AutomationId = "ResultLabel" | ||
| }; | ||
|
|
||
| var items = new ObservableCollection<string> { "Item 1", "Item 2", "Item 3" }; | ||
|
|
||
| var collectionView = new CollectionView() | ||
| { | ||
| SelectionMode = SelectionMode.Single, | ||
| AutomationId = "TestCollectionView", | ||
| HeightRequest = 300 | ||
| }; | ||
|
|
||
| collectionView.HeaderTemplate = new DataTemplate(() => | ||
| { | ||
| return new Label | ||
| { | ||
| Text = "Header", | ||
| FontSize = 18, | ||
| FontAttributes = FontAttributes.Bold, | ||
| Margin = new Thickness(10) | ||
| }; | ||
| }); | ||
|
|
||
| collectionView.ItemTemplate = new DataTemplate(() => | ||
| { | ||
| var label = new Label(); | ||
| label.SetBinding(Label.TextProperty, "."); | ||
| label.Margin = new Thickness(10); | ||
| label.FontSize = 16; | ||
| return label; | ||
| }); | ||
|
|
||
| collectionView.ItemsSource = items; | ||
| collectionView.SelectionChanged += (s, e) => | ||
| { | ||
| resultLabel.Text = "Success"; | ||
| }; | ||
|
|
||
| layout.Children.Add(resultLabel); | ||
| layout.Children.Add(collectionView); | ||
|
|
||
| Content = layout; | ||
| } | ||
| } | ||
Binary file added
BIN
+107 KB
...trols/tests/TestCases.Mac.Tests/snapshots/mac/LabelNotTruncatedWithMaxLines.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/Issue34120.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 Issue34120 : _IssuesUITest | ||
| { | ||
| public override string Issue => "Label text truncated in ScrollView when MaxLines is set"; | ||
|
|
||
| public Issue34120(TestDevice device) : base(device) { } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Label)] | ||
| public void LabelNotTruncatedWithMaxLines() | ||
| { | ||
| // Wait for the page to load, then verify labels are not truncated. | ||
| App.WaitForElement("Golden Snub-nosed Monkey"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34247.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,26 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue34247 : _IssuesUITest | ||
| { | ||
| public Issue34247(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "CollectionView with HeaderTemplate and SelectionMode.Single crashes on selection"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CollectionView)] | ||
| public void SelectingItemInCollectionViewWithHeaderTemplateDoesNotCrash() | ||
| { | ||
| App.WaitForElement("TestCollectionView"); | ||
| App.WaitForElement("Item 1"); | ||
| App.Tap("Item 1"); | ||
| var result = App.WaitForElement("ResultLabel").GetText(); | ||
| Assert.That(result, Is.EqualTo("Success")); | ||
|
NirmalKumarYuvaraj marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
Binary file added
BIN
+128 KB
...tests/TestCases.WinUI.Tests/snapshots/windows/LabelNotTruncatedWithMaxLines.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
+325 KB
...ls/tests/TestCases.iOS.Tests/snapshots/ios-26/LabelNotTruncatedWithMaxLines.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
+325 KB
...trols/tests/TestCases.iOS.Tests/snapshots/ios/LabelNotTruncatedWithMaxLines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.