maui
maui copied to clipboard
Lowercase char in Entry with TextTransform=Uppercase moves carret to the beginning
Description
Typing lowercase character in Entry with TextTransform="Uppercase" makes carret jump to the start of the entry. This causes typing next character at the beginning of the text. It happens only when typing lowercase character - and is being transformed to uppercase. Typing uppercase characters or numeric values doesn't cause this. Works fine on Windows platform.
Steps to Reproduce
Create default .NET MAUI App > .NET 7.0
Add <Entry **TextTransform="Uppercase"** />
to Main page (MainPage.xaml)
Run on Android 12.1 - API 32 emulator.
Press keys: 1 2 3 a b c d
Expected outcome: Entry is filled with value "123ABCD" and carret is at the end of the text.
Actual outcome: Entry is filled with value "DCB123A" and carret is at the beginning of the text.
Link to public reproduction project repository
https://github.com/richardoplustil/TextTransformUppercaseBug
Version with bug
7.0 (current)
Last version that worked well
6.0.424
Affected platforms
Android
Affected platform versions
Android 12.1
Did you find any workaround?
Removed TextTransform="Uppercase" attribute. Transforming to .UpperCase() later in ViewModel. Remains as-typed in the View.
Relevant log output
No response
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
I'm having this same issue.
Same problem. I would be interested to know how an upgrade to .Net 7.0 can cause such a huge problem. Was the code changed? I did a search in the repository, but I can't find the code where the actual work is being performed to transform the text.
Anyway, here is a workaround that helps me with another issue tied to the cursor. This is called from xaml via this method.
TextChanged="entry_name_TextChanged"
This method moves the cursor to the end of the text. I have not tested with the UpperCase problem.
private void entry_name_TextChanged(object sender, TextChangedEventArgs e)
{
Entry entry = sender as Entry;
#if ANDROID
if (!string.IsNullOrEmpty(e.NewTextValue))
{
//Access the CursorPosition via the Entry's x:Name
this.nameEntry.CursorPosition = entry.Text.Length + 1;
}
#endif
}
I have had the same issue since I upgraded to .NET 7
Me too I have had the same issue since I upgraded to .NET 7 on .NET 6 All work well
This is still an issue
Also confirmed. Android/.NET 7/Maui 7.0.52
This is a behavioral change, I previously had this implemented in the backing property like so and it seemed to work in Xamarin.Forms 5.
private string _myProp;
public string MyProp
{
get {
return _myProp;
}
set {
_myProp = value?.ToUpper();
NotifyPropertyChanged(nameof(MyProp));
}
}
Confirmed also with Scan Reader in keyboard emulation.
In the meanwhile you can use this workaround:
<Entry.Keyboard>
<Keyboard x:FactoryMethod="Create">
<x:Arguments>
<KeyboardFlags>CapitalizeCharacter</KeyboardFlags>
</x:Arguments>
</Keyboard>
</Entry.Keyboard>
please tell me how to fix this? damn after update MAUI still have this problem.. is it because im using Community Toolkit MVVM?
Can someone validate if this is fixed in .NET 8 preview1? We'd like to just get some user validation before considering this for backporting.