Skip to content
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

[release/8.0.1xx-sr9] Fixed Microsoft.Maui.Controls 8.0.90 (Latest stable) Ruins Entry Controls #25159

Merged
merged 13 commits into from
Oct 10, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25038.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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.Issue25038">

<StackLayout Padding="20">
<!-- First test case: Grid with entry having ClearButtonVisibility set to Never -->
<Grid x:Name="firstEntryGrid" IsVisible="False">
<Entry Text="Initial ClearButton Never Entry" x:Name="initialEntry" ClearButtonVisibility="Never" />
</Grid>

<!-- Second test case: Grid with entry where ClearButtonVisibility changes dynamically -->
<Grid x:Name="secondEntryGrid" IsVisible="False">
<Entry Text="Dynamic ClearButton Entry" x:Name="dynamicClearButtonEntry" ClearButtonVisibility="WhileEditing" />
</Grid>

<!-- Button to trigger the changes -->
<Button Text="Show Entries" AutomationId="button" Clicked="OnShowEntriesClicked"/>
</StackLayout>
</ContentPage>
27 changes: 27 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25038.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.Maui.Controls.Internals;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 25038, "MAUI Entry in Windows always shows ClearButton if initially hidden and shown even if ClearButtonVisibility set to 'Never'", PlatformAffected.UWP)]
public partial class Issue25038 : ContentPage
{
public Issue25038()
{
InitializeComponent();
}

private void OnShowEntriesClicked(object sender, EventArgs e)
{
// Show the first Grid
firstEntryGrid.IsVisible = true;

// Show the second Grid
secondEntryGrid.IsVisible = true;

// Change ClearButtonVisibility of the second Entry to Never
dynamicClearButtonEntry.ClearButtonVisibility = ClearButtonVisibility.Never;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue25038 : _IssuesUITest
{
public Issue25038(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "MAUI Entry in Windows always shows ClearButton if initially hidden and shown even if ClearButtonVisibility set to 'Never'";

[Test]
[Category(UITestCategories.Entry)]
[FailsOnMac]
public void VerifyEntryClearButtonVisibility()
{
App.WaitForElement("button");
App.Tap("button");
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/Core/src/Platform/Windows/MauiTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ static void OnIsDeleteButtonEnabledPropertyChanged(DependencyObject d, Dependenc
// Adjust the second column's width to 'Auto' when the delete button is enabled, and set it to zero when disabled.
if (deleteButton?.Parent is Grid rootGrid && rootGrid.ColumnDefinitions.Count > 1)
{
int deleteButtonColumnIndex = Grid.GetColumn(deleteButton);
if (GetIsDeleteButtonEnabled(element))
{
rootGrid.ColumnDefinitions[1].Width = new UI.Xaml.GridLength(1, UI.Xaml.GridUnitType.Auto);
rootGrid.ColumnDefinitions[deleteButtonColumnIndex].Width = new UI.Xaml.GridLength(1, UI.Xaml.GridUnitType.Auto);
}
else
{
rootGrid.ColumnDefinitions[1].Width = new UI.Xaml.GridLength(0);
rootGrid.ColumnDefinitions[deleteButtonColumnIndex].Width = new UI.Xaml.GridLength(0);
}
}
}
Expand Down