Skip to content

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

Closed

Description

@carlh98

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
  • 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

Activity

  1. added
    kind/bug
    platform/android 🤖
    triage/untriaged
    on Nov 6, 2019
  2. changed the title [-][Android] Flickering occurs when user enters a number in a TextBox with a Mask[/-] [+][Android] When you add a special character in a TextBox with a Mask, the cursor goes to the left 1 position[/+] on Nov 7, 2019
  3. changed the title [-][Android] When you add a special character in a TextBox with a Mask, the cursor goes to the left 1 position[/-] [+][Android] When you insert a special character in a TextBox with a Mask, the cursor goes to the left 1 position[/+] on Nov 7, 2019
  4. jeromelaban commented on Nov 8, 2019

    @jeromelaban
    Member

    Why was this issue closed ? Was it fixed ?

  5. carlh98 commented on Nov 8, 2019

    @carlh98
    ContributorAuthor

    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.

  6. XiaotianNetlift commented on Jan 7, 2020

    @XiaotianNetlift
    Contributor

    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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugplatform/android 🤖triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions