Uno: [Android] When you insert a special character in a TextBox with a Mask, the cursor goes to the left 1 position

Created on 6 Nov 2019  路  3Comments  路  Source: unoplatform/uno

Current behavior

In Android, when you insert a special character (ex: +, -, *, .) in a TextBox (the TextBox/mask needs to not be full/complete).
Ex: Mask is (00000)

  • you have entered 123 and you try to add a special character, the cursor will go to the left for 1 position
  • the TextBox is empty and you try to add a special character, the first parenthesis of the mask will appear
  • you have entered 12345 and you try to add a special character, the second parenthesis of the mask will appear

The TextBox needs to have InputScope="TelephoneNumber"

When the mask is not full, you try to add a special character and the cursor moves to the left

Expected behavior

When the mask is not full, you try to add a special character and the TextBox stays at the same position

How to reproduce it (as minimally and precisely as possible)


Add a special character with the pad to the TextBox and the cursor will move one position to the left

Use the following sample: TextBoxFormattingSample.zip

Environment

Nuget Package:

Uno.UI = 2.0.512-dev.3599
Umbrella.View = 3.8.0-dev.414

Package Version(s):

Affected platform(s):

  • [ ] iOS
  • [x] Android
  • [ ] WebAssembly
  • [ ] WebAssembly renderers for Xamarin.Forms
  • [ ] Windows
  • [ ] Build tasks
  • [ ] Solution Templates

Visual Studio:

  • [ ] 2017 (version: )
  • [ ] 2019 (version: )
  • [ ] for Mac (version: )

Relevant plugins:

  • [ ] Resharper (version: )

Anything else we need to know?


https://dev.azure.com/nventive/Umbrella/_workitems/edit/164249

kinbug platforandroid triaguntriaged

Most helpful comment

This issue can remain closed. The root cause is that the FormattingTextBoxBehavior, which not part of Uno.UI, simply re-adjusts cursor position based on the delta in text length, regardless of the modification(s) occurred before or after the cursor position:

var selectionStart = textbox.SelectionStart;
if (textbox.Text.Length > formattedText.Length) // Non-considered special chars were removed.
{
  selectionStart -= textbox.Text.Length - formattedText.Length;
}
else // String format chars were added.
{
  selectionStart += GetAddedFormattingCharacterCount(textbox);
}

-- https://nventive.visualstudio.com/Umbrella/_workitems/edit/164249/

All 3 comments

Why was this issue closed ? Was it fixed ?

I've changed the InputScope from Number to TelephoneNumber and the issue of flickering has stopped.
There's now an issue with the cursor moving left but it's related to Umbrella.

This issue can remain closed. The root cause is that the FormattingTextBoxBehavior, which not part of Uno.UI, simply re-adjusts cursor position based on the delta in text length, regardless of the modification(s) occurred before or after the cursor position:

var selectionStart = textbox.SelectionStart;
if (textbox.Text.Length > formattedText.Length) // Non-considered special chars were removed.
{
  selectionStart -= textbox.Text.Length - formattedText.Length;
}
else // String format chars were added.
{
  selectionStart += GetAddedFormattingCharacterCount(textbox);
}

-- https://nventive.visualstudio.com/Umbrella/_workitems/edit/164249/

Was this page helpful?
0 / 5 - 0 ratings