-
Notifications
You must be signed in to change notification settings - Fork 2k
[Windows] Fix SwipeItem IsVisible not refreshing native swipe items when binding changes #35361
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 all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f7b120
[Windows] SwipeItem.IsVisible has no effect on Windows
SubhikshaSf4851 9a90c32
SwipeItem Changes
SubhikshaSf4851 c16dd53
Fixed Windows hidden to Isvisibility true
SubhikshaSf4851 04ce13b
Updated Test sample
SubhikshaSf4851 018ead4
Updated suggestion
SubhikshaSf4851 2215f41
Added Windows Snapshot
SubhikshaSf4851 8853e24
Added recommended suggestion
SubhikshaSf4851 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
Some comments aren't visible on the classic Files Changed page.
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
100 changes: 100 additions & 0 deletions
100
src/Controls/tests/TestCases.HostApp/Issues/Issue35216.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,100 @@ | ||
| using System.ComponentModel; | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 35216, "SwipeItem IsVisible should properly refresh native swipe items when binding value changes dynamically", PlatformAffected.UWP)] | ||
| public class Issue35216 : ContentPage | ||
| { | ||
| readonly Issue35216ViewModel _viewModel = new() { IsDeleteVisible = false }; | ||
| SwipeView _swipeView; | ||
|
|
||
| public Issue35216() | ||
| { | ||
| BindingContext = _viewModel; | ||
|
|
||
| SwipeItem deleteSwipeItem = new SwipeItem | ||
| { | ||
| Text = "Delete", | ||
| BackgroundColor = Colors.Green, | ||
| AutomationId = "DeleteSwipeItem" | ||
| }; | ||
| deleteSwipeItem.SetBinding(SwipeItem.IsVisibleProperty, new Binding(nameof(Issue35216ViewModel.IsDeleteVisible))); | ||
|
|
||
| SwipeItem archiveSwipeItem = new SwipeItem | ||
| { | ||
| Text = "Archive", | ||
| BackgroundColor = Colors.Blue, | ||
| AutomationId = "ArchiveSwipeItem" | ||
| }; | ||
|
|
||
| _swipeView = new SwipeView | ||
| { | ||
| HeightRequest = 60, | ||
| LeftItems = new SwipeItems { deleteSwipeItem, archiveSwipeItem }, | ||
| Content = new Grid | ||
| { | ||
| BackgroundColor = Colors.LightGray, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| AutomationId = "SwipeContent", | ||
| Text = "Swipe right to reveal items", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| Button toggleButton = new Button | ||
| { | ||
| Text = "Toggle Delete Visibility", | ||
| AutomationId = "ToggleVisibilityButton" | ||
| }; | ||
| toggleButton.Clicked += (s, e) => _viewModel.IsDeleteVisible = !_viewModel.IsDeleteVisible; | ||
|
|
||
| Button resetButton = new Button | ||
| { | ||
| Text = "Reset", | ||
| AutomationId = "ResetButton" | ||
| }; | ||
| resetButton.Clicked += (s, e) => _viewModel.IsDeleteVisible = false; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Padding = new Thickness(20), | ||
| Spacing = 20, | ||
| Children = | ||
| { | ||
| _swipeView, | ||
| toggleButton, | ||
| resetButton, | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public class Issue35216ViewModel : INotifyPropertyChanged | ||
| { | ||
| bool _isDeleteVisible; | ||
|
|
||
| public bool IsDeleteVisible | ||
| { | ||
| get => _isDeleteVisible; | ||
| set | ||
| { | ||
| if (_isDeleteVisible != value) | ||
| { | ||
| _isDeleteVisible = value; | ||
| OnPropertyChanged(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public event PropertyChangedEventHandler PropertyChanged; | ||
|
|
||
| protected void OnPropertyChanged([CallerMemberName] string name = null) => | ||
| PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); | ||
| } |
75 changes: 75 additions & 0 deletions
75
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35216.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,75 @@ | ||
| #if WINDOWS // Existing PR for iOS & Android: https://github.com/dotnet/maui/pull/35217 | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue35216 : _IssuesUITest | ||
| { | ||
| public override string Issue => "SwipeItem IsVisible should properly refresh native swipe items when binding value changes dynamically"; | ||
|
|
||
| public Issue35216(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| [Test] | ||
| [Order(1)] | ||
| [Category(UITestCategories.SwipeView)] | ||
| public void Issue35216SwipeItemInitiallyHiddenBecomesVisibleAfterBindingChanges() | ||
| { | ||
| Exception? exception = null; | ||
| var rect = App.WaitForElement("SwipeContent").GetRect(); | ||
| var centerX = rect.X + rect.Width / 2; | ||
| var centerY = rect.Y + rect.Height / 2; | ||
|
|
||
| App.DragCoordinates(centerX, centerY, centerX + 200, centerY); | ||
|
|
||
| VerifyScreenshotOrSetException(ref exception, "Issue35216SwipeOpen_InitiallyHidden", | ||
| retryTimeout: TimeSpan.FromSeconds(2), tolerance: 1.0); | ||
|
|
||
| App.Tap("ToggleVisibilityButton"); | ||
|
|
||
| App.DragCoordinates(centerX, centerY, centerX + 200, centerY); | ||
|
SubhikshaSf4851 marked this conversation as resolved.
SubhikshaSf4851 marked this conversation as resolved.
SubhikshaSf4851 marked this conversation as resolved.
|
||
| VerifyScreenshotOrSetException(ref exception, "Issue35216SwipeOpen_BecomeVisible", | ||
| retryTimeout: TimeSpan.FromSeconds(2), tolerance: 1.0); | ||
|
|
||
| App.Tap("ResetButton"); | ||
|
|
||
| if (exception is not null) | ||
| { | ||
| throw exception; | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| [Order(2)] | ||
| [Category(UITestCategories.SwipeView)] | ||
| public void Issue35216SwipeItemBecomesHiddenAfterBindingChanges() | ||
| { | ||
| Exception? exception = null; | ||
| var rect = App.WaitForElement("SwipeContent").GetRect(); | ||
| var centerX = rect.X + rect.Width / 2; | ||
| var centerY = rect.Y + rect.Height / 2; | ||
|
|
||
| App.Tap("ToggleVisibilityButton"); | ||
| App.DragCoordinates(centerX, centerY, centerX + 200, centerY); | ||
|
|
||
| VerifyScreenshotOrSetException(ref exception, "Issue35216SwipeOpen_DeleteVisible", | ||
| retryTimeout: TimeSpan.FromSeconds(2), tolerance: 1.0); | ||
|
|
||
| App.Tap("ToggleVisibilityButton"); | ||
|
|
||
| App.DragCoordinates(centerX, centerY, centerX + 200, centerY); | ||
| VerifyScreenshotOrSetException(ref exception, "Issue35216SwipeOpen_DeleteHidden", | ||
| retryTimeout: TimeSpan.FromSeconds(2), tolerance: 1.0); | ||
|
|
||
| App.Tap("ResetButton"); | ||
|
|
||
| if (exception is not null) | ||
| { | ||
| throw exception; | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
Binary file added
BIN
+11.3 KB
...s/TestCases.WinUI.Tests/snapshots/windows/Issue35216SwipeOpen_BecomeVisible.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
+10.8 KB
...ts/TestCases.WinUI.Tests/snapshots/windows/Issue35216SwipeOpen_DeleteHidden.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
+11.3 KB
...s/TestCases.WinUI.Tests/snapshots/windows/Issue35216SwipeOpen_DeleteVisible.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
+10.9 KB
...TestCases.WinUI.Tests/snapshots/windows/Issue35216SwipeOpen_InitiallyHidden.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
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.
Uh oh!
There was an error while loading. Please reload this page.