maui icon indicating copy to clipboard operation
maui copied to clipboard

Lowercase char in Entry with TextTransform=Uppercase moves carret to the beginning

Open richardoplustil opened this issue 2 years ago • 2 comments

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. image

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

richardoplustil avatar Nov 12 '22 15:11 richardoplustil

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.

ghost avatar Nov 14 '22 15:11 ghost

I'm having this same issue.

petes05 avatar Nov 24 '22 15:11 petes05

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
    }

faceoffers28 avatar Dec 04 '22 18:12 faceoffers28

I have had the same issue since I upgraded to .NET 7

MahmoudAlEssawi avatar Dec 08 '22 12:12 MahmoudAlEssawi

Me too I have had the same issue since I upgraded to .NET 7 on .NET 6 All work well

cmsdesigner avatar Dec 12 '22 16:12 cmsdesigner

This is still an issue

HobDev avatar Dec 31 '22 02:12 HobDev

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));
		}
	}

shadowfoxish avatar Jan 13 '23 21:01 shadowfoxish

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>

nbiada avatar Jan 15 '23 11:01 nbiada

please tell me how to fix this? damn after update MAUI still have this problem.. is it because im using Community Toolkit MVVM?

a7son avatar Feb 07 '23 09:02 a7son

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.

PureWeen avatar Mar 09 '23 15:03 PureWeen