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

Resolved Text Jump Issue in Entry Control with HorizontalTextAlignment Set to End #24485

Merged
merged 16 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
PureWeen marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading