forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Windows] Respect `ClearButtonVisibility = ClearButtonVisibility.Neve…
…r` for `<Entry>`s (dotnet#23158) ### Description of Change The style interception code works sometimes but not always. Relevant XAML template in WinUI 3 is [here](https://github.com/microsoft/microsoft-ui-xaml/blob/98a60c8f30c84f297a175dd2884d54ecd1c8a4a9/controls/dev/CommonStyles/TextBox_themeresources.xaml#L311-L341). ### Issues Fixed Fixes dotnet#23112 Related to dotnet#13714 PR that introduced the modified code: dotnet#3444
- Loading branch information
Showing
7 changed files
with
102 additions
and
50 deletions.
There are no files selected for viewing
Binary file added
BIN
+134 KB
....Android.Tests/snapshots/android/ValidateEntryClearButtonVisibilityBehavior.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.HostApp/Issues/Issue23158.xaml
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,26 @@ | ||
<?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" | ||
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues" | ||
x:Class="Maui.Controls.Sample.Issues.Issue23158" | ||
x:DataType="local:Issue23158"> | ||
|
||
<VerticalStackLayout Padding="30,0"> | ||
<Button AutomationId="AddEntry" Text="Add entry dynamically" Margin="0,0,0,30" Clicked="AddEntryButton_Clicked"/> | ||
|
||
<!-- First entry. --> | ||
<Label Text="Entry.ClearButtonVisibility=Never"/> | ||
<Entry x:Name="Entry1" ClearButtonVisibility="Never" Text="A"/> | ||
|
||
<!-- Second entry. --> | ||
<Label Text="Entry.ClearButtonVisibility=WhileEditing"/> | ||
<Entry x:Name="Entry2" ClearButtonVisibility="WhileEditing" Text="B"/> | ||
|
||
<!-- Third entry. See #23112. --> | ||
<Label Text="Dynamically Entry.ClearButtonVisibility=Never + Focus"/> | ||
<VerticalStackLayout x:Name="Entry3Container"/> <!-- Container for a dynamically added entry. --> | ||
|
||
<Label AutomationId="TestInstructions" Margin="0,30,0,0" FontAttributes="Bold" | ||
Text="Instructions: Click the top-most button and the third entry should not contain any clear button!"/> | ||
</VerticalStackLayout> | ||
</ContentPage> |
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.HostApp/Issues/Issue23158.xaml.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,26 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 23158, "Respect Entry.ClearButtonVisibility on Windows", PlatformAffected.UWP)] | ||
public partial class Issue23158 : ContentPage | ||
{ | ||
public Issue23158() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void AddEntryButton_Clicked(object sender, EventArgs e) | ||
{ | ||
Entry entry = new Entry() | ||
{ | ||
Text = "Some Text", | ||
AutomationId = "Entry3" | ||
}; | ||
|
||
Entry3Container.Children.Add(entry); | ||
|
||
// Intentionally, after the entry is added to its layout container. | ||
entry.ClearButtonVisibility = ClearButtonVisibility.Never; | ||
entry.Focus(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23158.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,31 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue23158 : _IssuesUITest | ||
{ | ||
public override string Issue => "Respect Entry.ClearButtonVisibility on Windows"; | ||
|
||
public Issue23158(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
#if !MACCATALYST | ||
[Test] | ||
[Category(UITestCategories.Entry)] | ||
public void ValidateEntryClearButtonVisibilityBehavior() | ||
{ | ||
App.WaitForElement("TestInstructions"); | ||
|
||
// Click the button to add dynamically Entry3. | ||
App.Click("AddEntry"); | ||
|
||
// Click the new entry to see if there is the clear button or not. No such button should be present. | ||
App.Tap("Entry3"); | ||
|
||
VerifyScreenshot(); | ||
} | ||
#endif | ||
} |
Binary file added
BIN
+17 KB
...es.WinUI.Tests/snapshots/windows/ValidateEntryClearButtonVisibilityBehavior.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
+172 KB
...estCases.iOS.Tests/snapshots/ios/ValidateEntryClearButtonVisibilityBehavior.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 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