-
Notifications
You must be signed in to change notification settings - Fork 2k
[Android/iOS] Fix IsEnabled=False on CollectionView not working #27749
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 all commits
8aaba58
6bf647d
e2e485d
0042544
7df778c
df4d977
659eaf9
c107813
3539a25
ba6e356
a94279e
9871889
53e0e49
6e5936b
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,27 @@ | ||
| <?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.Issue20274" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"> | ||
|
|
||
| <Grid RowDefinitions="auto,auto, *"> | ||
| <Button Text="Change State" AutomationId="Button" Clicked="Button_Clicked"/> | ||
| <Label Grid.Row="1" AutomationId="Label" HeightRequest="50" VerticalTextAlignment="Center" x:Name="label"/> | ||
| <CollectionView | ||
| Grid.Row="2" IsEnabled="False" | ||
| SelectionMode="Single" x:Name="collectionView" SelectionChanged="collectionView_SelectionChanged" | ||
| ItemsSource="{Binding Items}"> | ||
| <CollectionView.ItemTemplate> | ||
| <DataTemplate> | ||
| <Label Margin="10" | ||
| Padding="10" | ||
| AutomationId="ItemsLabel" | ||
| VerticalTextAlignment="Center" | ||
| HorizontalTextAlignment="Start" | ||
| Text="{Binding Name}" /> | ||
| </DataTemplate> | ||
| </CollectionView.ItemTemplate> | ||
| </CollectionView> | ||
| </Grid> | ||
|
|
||
| </ContentPage> |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||
| using System.Collections.ObjectModel; | ||||||||
| using System.ComponentModel; | ||||||||
|
|
||||||||
| namespace Maui.Controls.Sample.Issues | ||||||||
| { | ||||||||
| [Issue(IssueTracker.Github, 20274, "IsEnabled=False on CollectionView not working", PlatformAffected.All)] | ||||||||
| public partial class Issue20274 : ContentPage | ||||||||
| { | ||||||||
| public ObservableCollection<CollectionViewItem> Items { get; set; } | ||||||||
|
|
||||||||
| public Issue20274() | ||||||||
| { | ||||||||
| Items = new ObservableCollection<CollectionViewItem> | ||||||||
| { | ||||||||
| new CollectionViewItem { Name = "Item 1" }, | ||||||||
| new CollectionViewItem { Name = "Item 2" }, | ||||||||
| new CollectionViewItem { Name = "Item 3" } | ||||||||
| }; | ||||||||
| InitializeComponent(); | ||||||||
| BindingContext = this; | ||||||||
| label.Text = Items[0].Name; | ||||||||
| } | ||||||||
|
|
||||||||
| void collectionView_SelectionChanged(object sender, SelectionChangedEventArgs e) | ||||||||
| { | ||||||||
| if (e.CurrentSelection?.FirstOrDefault() is CollectionViewItem selectedItem) | ||||||||
| { | ||||||||
| selectedItem.Name = $"{selectedItem.Name} - Selected"; | ||||||||
| this.label.Text = selectedItem.Name; | ||||||||
|
Comment on lines
+28
to
+29
|
||||||||
| selectedItem.Name = $"{selectedItem.Name} - Selected"; | |
| this.label.Text = selectedItem.Name; | |
| this.label.Text = $"{selectedItem.Name} - Selected"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue20274 : _IssuesUITest | ||
| { | ||
| public override string Issue => "IsEnabled=False on CollectionView not working"; | ||
|
|
||
| public Issue20274(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CollectionView)] | ||
| public void VerifyCollectionViewIsEnableState() | ||
| { | ||
| App.WaitForElement("Button"); | ||
| App.Tap("ItemsLabel"); | ||
| Assert.That(App.FindElement("Label").GetText(), Is.EqualTo("Item 1")); | ||
| App.Tap("Button"); | ||
| App.Tap("ItemsLabel"); | ||
| Assert.That(App.FindElement("Label").GetText(), Is.EqualTo("Item 1 - Selected")); | ||
| } | ||
| } | ||
| } |
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.
The test files are using issue number
20274in both the file names and code, but the PR description indicates this PR fixes issue #27770. The issue numbers should match. Consider renaming the test files toIssue27770.cs,Issue27770.xaml, andIssue27770.xaml.cs, and updating the[Issue]attribute to reference the correct issue number 27770.