-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android, iOS] Fix for CollectionView and CarouselView remain interactive when disabled #32794
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
Open
SyedAbdulAzeemSF4852
wants to merge
4
commits into
dotnet:main
Choose a base branch
from
SyedAbdulAzeemSF4852:fix-carouselview-swiping-when-disabled
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+152
−6
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
db620ac
[Android & iOS] Fix for CarouselView remains swipeable even when disa…
SyedAbdulAzeemSF4852 a9c4cfa
Modified the fix and the test case, and re-enabled the Windows test
SyedAbdulAzeemSF4852 aaffcbf
Renamed file and updated class name to align with the issue ID
SyedAbdulAzeemSF4852 9aac492
Added a short delay to wait for transition completion
SyedAbdulAzeemSF4852 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
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
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
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
1 change: 1 addition & 0 deletions
1
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #nullable enable | ||
| ~override Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView<TItemsView, TAdapter, TItemsViewSource>.OnInterceptTouchEvent(Android.Views.MotionEvent ev) -> bool |
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,65 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 32791, "Setting the IsEnabled property of the CarouselView to false does not prevent swiping through items", PlatformAffected.Android | PlatformAffected.iOS )] | ||
| public class Issue32791 : ContentPage | ||
| { | ||
| CarouselView _carouselView; | ||
| Label _statusLabel; | ||
| public Issue32791() | ||
| { | ||
| _carouselView = new CarouselView | ||
| { | ||
| AutomationId = "DisabledCarouselView", | ||
| HeightRequest = 300, | ||
| IsEnabled = false, | ||
| Loop = false, | ||
| ItemsSource = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }, | ||
| ItemTemplate = new DataTemplate(() => | ||
| { | ||
| Label label = new Label | ||
| { | ||
| FontSize = 32, | ||
| BackgroundColor = Colors.LightGray, | ||
| Padding = 20, | ||
| HorizontalOptions = LayoutOptions.Fill, | ||
| VerticalOptions = LayoutOptions.Fill | ||
| }; | ||
| label.SetBinding(Label.TextProperty, "."); | ||
|
|
||
| return label; | ||
| }) | ||
| }; | ||
|
|
||
| _carouselView.CurrentItemChanged += OnCarouselViewCurrentItemChanged; | ||
|
|
||
| _statusLabel = new Label | ||
| { | ||
| AutomationId = "Issue32791StatusLabel", | ||
| Text = "Success", | ||
| }; | ||
|
|
||
| Grid grid = new Grid | ||
| { | ||
| Padding = 20, | ||
| RowSpacing = 20, | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = new GridLength(300) }, | ||
| new RowDefinition { Height = GridLength.Auto } | ||
| } | ||
| }; | ||
|
|
||
| grid.Add(_carouselView, 0, 0); | ||
| grid.Add(_statusLabel, 0, 1); | ||
|
|
||
| Content = grid; | ||
| } | ||
|
|
||
| void OnCarouselViewCurrentItemChanged(object sender, CurrentItemChangedEventArgs e) | ||
| { | ||
| if (e.CurrentItem?.ToString() != "Item 1") | ||
| { | ||
| _statusLabel.Text = "Failure"; | ||
| } | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32791.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,29 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue32791 : _IssuesUITest | ||
| { | ||
| public Issue32791(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Setting the IsEnabled property of the CarouselView to false does not prevent swiping through items"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CarouselView)] | ||
| public void VerifyCarouselViewPreventsSwipingWhenDisabled() | ||
| { | ||
| App.WaitForElement("DisabledCarouselView"); | ||
| App.ScrollRight("DisabledCarouselView"); | ||
|
|
||
| #if MACCATALYST | ||
| // MacCatalyst: Wait for item transition to complete after scroll gesture | ||
| Thread.Sleep(1000); | ||
| #endif | ||
| var statusText = App.WaitForElement("Issue32791StatusLabel").GetText(); | ||
| Assert.That(statusText, Is.EqualTo("Success")); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
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.
Platform-conditional compilation with
Thread.Sleepin the test can hide test failures on MacCatalyst. If the sleep is truly necessary for MacCatalyst, consider documenting why, or better yet, use a proper wait mechanism.According to the UI testing guidelines, tests should use
App.WaitForElementor similar explicit waits rather than arbitrary sleeps. If there's a specific element state you're waiting for on MacCatalyst, wait for that explicitly.