Skip to content

Commit

Permalink
Resolved Text Jump Issue in Entry Control with HorizontalTextAlignmen…
Browse files Browse the repository at this point in the history
…t Set to End (#24485)

* fix-24405-Fixed-Entry-Text-Alignment-Issue

* Fix-24405-Removed local variable and added old comment.

* fix-24405-Testcase sample updated.

* Fix-24405-Test case changes committed.

* fix-24405-Updated new logic.

* fix-24405-Test script changes committed.

* fix-24405-Modified script and sample files.

* fix-24405-Modified test sample code.

* Fix-24405-Snapshots added for windows, iOS and Android.

* Fix-24405-Updated Testscript method name.
  • Loading branch information
BagavathiPerumal authored Sep 6, 2024
1 parent bc5b90b commit 9486321
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24405.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?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.Issue24405">
<VerticalStackLayout>
<Entry AutomationId="entry" x:Name="entry" Placeholder="Enter text here" HorizontalTextAlignment="End"/>
<Button AutomationId="button" Text="Click" Clicked="OnButtonClicked"/>
</VerticalStackLayout>
</ContentPage>
26 changes: 26 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24405.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.CustomAttributes;
using Microsoft.Maui.Controls.Internals;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 24405, "Entry with right aligned text keeps text jumping to the left during editing", PlatformAffected.UWP)]
public partial class Issue24405 : ContentPage
{
public Issue24405()
{
InitializeComponent();
}

private void OnButtonClicked(object sender, EventArgs e)
{
entry.Text = "Hello";
}
}
}
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 Issue24405 : _IssuesUITest
{
public Issue24405(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Entry with right aligned text keeps text jumping to the left during editing";

[Test]
[Category(UITestCategories.Entry)]
[FailsOnMac]
public void VerifyEntryHorizontalEndTextAlignmentPosition()
{
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.
8 changes: 4 additions & 4 deletions src/Core/src/Platform/Windows/MauiTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ static void OnIsDeleteButtonEnabledPropertyChanged(DependencyObject d, Dependenc

Button? deleteButton = element.GetDescendantByName<Button>(DeleteButtonElementName);

if (deleteButton is not null)
// 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)
{
if (GetIsDeleteButtonEnabled(element))
{
deleteButton.RenderTransform = null;
rootGrid.ColumnDefinitions[1].Width = new UI.Xaml.GridLength(1, UI.Xaml.GridUnitType.Auto);
}
else
{
// This is a workaround to move the button to be effectively invisible. It is not perfect.
deleteButton.RenderTransform = new TranslateTransform() { X = -int.MaxValue, Y = -int.MaxValue };
rootGrid.ColumnDefinitions[1].Width = new UI.Xaml.GridLength(0);
}
}
}
Expand Down

0 comments on commit 9486321

Please sign in to comment.