-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Windows] Fixed TextCell Command executes only once #25066
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d5c88e9
Fixed-21112 : TableView TextCell command executes only once
Vignesh-SF3580 06c84b5
added test cases.
Vignesh-SF3580 66c6cd5
updated testcases.
Vignesh-SF3580 cfbaad4
updated Issues/Issue21112.cs
Vignesh-SF3580 fffaac0
Updated testcases.
Vignesh-SF3580 6cb8b09
updated testcases.
Vignesh-SF3580 98098ea
testcases updated.
Vignesh-SF3580 fa61fae
updated testcases.
Vignesh-SF3580 40cb715
viewmodel name updated with IssueId.
Vignesh-SF3580 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 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
111 changes: 111 additions & 0 deletions
111
src/Controls/tests/TestCases.HostApp/Issues/Issue21112.cs
This file contains 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,111 @@ | ||
using System.Windows.Input; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 21112, "TableView TextCell command executes only once", PlatformAffected.UWP)] | ||
public class Issue21112 : NavigationPage | ||
{ | ||
public Issue21112() : base(new MainPage()) | ||
{ | ||
|
||
} | ||
} | ||
|
||
public class MainPage : ContentPage | ||
{ | ||
public MainPage() | ||
{ | ||
var stackLayout = new StackLayout(); | ||
BindingContext = new MainViewModel(); | ||
|
||
var headerTextCell = new TextCell | ||
{ | ||
Text = "Header demo", | ||
Detail = "Absolute positioning and sizing" | ||
}; | ||
|
||
headerTextCell.SetBinding(TextCell.CommandProperty, new Binding("NavigateCommand")); | ||
headerTextCell.CommandParameter = typeof(DemoPage); | ||
|
||
var tableView = new TableView | ||
{ | ||
Intent = TableIntent.Menu, | ||
Root = new TableRoot | ||
{ | ||
new TableSection("XAML") | ||
{ | ||
headerTextCell | ||
} | ||
} | ||
}; | ||
|
||
var button = new Button | ||
{ | ||
Text = "Trigger TextCell Click", | ||
AutomationId = "MainPageButton" | ||
}; | ||
|
||
button.Clicked += (sender, e) => | ||
{ | ||
headerTextCell.Command.Execute(headerTextCell.CommandParameter); | ||
}; | ||
|
||
stackLayout.Children.Add(tableView); | ||
stackLayout.Children.Add(button); | ||
|
||
Content = stackLayout; | ||
} | ||
} | ||
|
||
public partial class DemoPage : ContentPage | ||
{ | ||
public DemoPage() | ||
{ | ||
Title = "Text demo"; | ||
|
||
var button = new Button | ||
{ | ||
AutomationId = "NavigatedPageButton", | ||
Text = "Click" | ||
}; | ||
|
||
var label = new Label | ||
{ | ||
AutomationId = "NavigatedPageLabel", | ||
Text = "Main Page" | ||
}; | ||
|
||
button.Clicked += (sender, e) => | ||
{ | ||
Navigation.PopAsync(); | ||
}; | ||
|
||
Content = new StackLayout | ||
{ | ||
Children = | ||
{ | ||
button, | ||
label | ||
} | ||
}; | ||
} | ||
} | ||
|
||
public class MainViewModel | ||
{ | ||
public ICommand NavigateCommand { get; set; } | ||
|
||
public MainViewModel() | ||
{ | ||
NavigateCommand = new Command<Type>(async (Type pageType) => | ||
{ | ||
Page page = Activator.CreateInstance(pageType) as Page; | ||
if (page is not null) | ||
{ | ||
await Application.Current.MainPage.Navigation.PushAsync(page); | ||
} | ||
}); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21112.cs
This file contains 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,28 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue21112 : _IssuesUITest | ||
{ | ||
public Issue21112(TestDevice testDevice) : base(testDevice) | ||
{ | ||
} | ||
public override string Issue => "TableView TextCell command executes only once"; | ||
|
||
[Test] | ||
[Category(UITestCategories.TableView)] | ||
public void TableViewTextCellCommand() | ||
{ | ||
App.WaitForElement("MainPageButton"); | ||
App.Tap("MainPageButton"); | ||
App.WaitForElement("NavigatedPageButton"); | ||
App.Tap("NavigatedPageButton"); | ||
App.WaitForElement("MainPageButton"); | ||
App.Tap("MainPageButton"); | ||
var label = App.WaitForElement("NavigatedPageLabel"); | ||
Assert.That(label.GetText(), Is.EqualTo("Main Page")); | ||
} | ||
} | ||
} |
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.
The build is failing:
Another sample is already using a MainViewModel, my recommendation here is always use the issue id to create view models etc. For example:
Issue21112ViewModel
or Issue21112MainView etc.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've updated the code based on your feedback. Could you please review it and let me know if there are any further concerns