Skip to content

TextField with maxLength needs multiple delete taps to delete text  #67828

Closed

Description

@mehmetf

b/170458334

This can be repro'ed using the sample at: https://flutter.dev/docs/cookbook/forms/retrieve-input

Add maxLength: 5 to the TextField widget and try entering: "123456789" to the text field. You will need to press backspace 5 times to start deleting the text. My hunch is that we are not storing the inner "cursor position" correctly. The data seems to be correct (pressing the FAB always returns 12345).

I recall this used to work so marking as regression.

Activity

  1. elMuso commented on Oct 10, 2020

    @elMuso

    The same happens when using FilteringTextInputFormatter, i use

    inputFormatters: [
                        FilteringTextInputFormatter.digitsOnly,
    

    and i enter 123456abc , the text shows 123456 , but i need to delete 3 times (abc) before i'm able to delete the numbers. Is this the intended behaviour? even using a custom TextInputFormatter to never change the text it stills preserves a "history".

    The issue seems to be fixed once i remove the focus of the textfield and focus it again. Then it seems that internally 123456abc becomes 123456

    -flutter doctor

    [√] Flutter (Channel beta, 1.22.1, on Microsoft Windows [Versión 10.0.18362.239], locale es-ES)
     
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    [X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
        ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
    [√] Android Studio (version 4.0)
    [!] IntelliJ IDEA Community Edition (version 2018.2)
        X Flutter plugin not installed; this adds Flutter specific functionality.
        X Dart plugin not installed; this adds Dart specific functionality.
    [√] VS Code (version 1.49.0)
    [√] Connected device (1 available)
    
  2. lstimac commented on Oct 10, 2020

    @lstimac

    I noticed this issue today too, I'm using inputFormatters with digits only filter along with the max length of 6. It seems like there is a counter or something internally which means even if I limit my input to 6 characters, each additional character will not appear in the input field, but it will be counted and will disrupt backspace functionality (nothing gets deleted until you reach the "real" input text).

    Let's hope this will be fixed ASAP as it is a pretty severe bug for such a widely used functionality.

    Flutter doctor

    [√] Flutter (Channel stable, 1.22.0, on Microsoft Windows [Version 10.0.18363.778],
        locale en-GB)
    
    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [√] Android Studio (version 3.6)
    [√] VS Code (version 1.49.3)
    [√] Connected device (1 available)
    
    • No issues found!
    
    
  3. pedromassango commented on Oct 11, 2020

    @pedromassango
    Member

    Duplicate of #67236

  4. xu-baolin commented on Oct 12, 2020

    @xu-baolin
    Member

    I am posting the fix PR now.

  5. github-actions commented on Aug 10, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Aug 10, 2021
  7. added
    P0Critical issues such as a build break or regression
    and removed on Jun 28, 2023
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

    P0Critical issues such as a build break or regressiona: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowcustomer: money (g3)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions