Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextInputType.number deletes 2 chars at once when hitting delete #70744

Closed
joachimvalente opened this issue Nov 18, 2020 · 24 comments · Fixed by flutter/engine#22626
Closed

TextInputType.number deletes 2 chars at once when hitting delete #70744

joachimvalente opened this issue Nov 18, 2020 · 24 comments · Fixed by flutter/engine#22626
Assignees
Labels
a: text input Entering text in a text field or keyboard related problems c: regression It was better in the past than it is now customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: money (g3) found in release: 1.24 Found to occur in 1.24 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression

Comments

@joachimvalente
Copy link

joachimvalente commented Nov 18, 2020

Internal: b/173579423

Steps to Reproduce

  1. Run flutter create bug.
  2. Update the files as follows:
// main.dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Test test test'),
        ),
        // TextField is also broken
        body: TextFormField(
          // .number also broken
          // but .text, .url, etc all work fine
          keyboardType: TextInputType.phone,
        ));
  }
}
  • flutter run
  • Type "12345" in the text field
  • Hit "delete"
  • => this will delete 4 and 5 at once
  • Hit "delete" again
  • => this will delete 2 and 3 at once

Expected results:
It should only delete one char at a time.

Actual results:
It deletes 2 chars at a time.

Logs
$ flutter run --verbose

https://gist.github.com/joachimvalente/df23aef38b4db835d132544081f6e905

$ flutter analyze
Analyzing tmptmp...                                                     
No issues found! (ran in 8.1s)
$ flutter doctor -v
[✓] Flutter (Channel master, 1.24.0-8.0.pre.291, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-US)
    • Flutter version 1.24.0-8.0.pre.291 at /Users/joachim/github/flutter
    • Framework revision c1042314a9 (37 minutes ago), 2020-11-18 01:38:02 -0500
    • Engine revision 35a0b9fe68
    • Dart version 2.12.0 (build 2.12.0-50.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/joachim/Library/Android/sdk
    • Platform android-30, build-tools 30.0.1
    • ANDROID_HOME = /Users/joachim/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 48.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.51.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (1 available)
    • Pixel 3 (mobile) • 89KX0AW01 • android-arm64 • Android 11 (API 30)

• No issues found!
@pedromassangocode pedromassangocode changed the title TextFormField with phone input deletes 2 chars at once when hitting delete TextInputType.number deletes 2 chars at once when hitting delete Nov 18, 2020
@pedromassangocode
Copy link

pedromassangocode commented Nov 18, 2020

Reproducible on master and NOT in beta/stable channel.

The issue is reproducible with:

  • TextInputType.number
  • TextInputType.phone
  • TextInputType.datetime

Or basically any keyboardType related to numbers.

gif

This is similar but different from #70581 because #70581 reproduces with Chinese characters only and with a text field without keyboardType.

Related to #67898.

Adding crowd because it impact lots of users.

flutter doctor -v
[✓] Flutter (Channel master, 1.24.0-8.0.pre.291, on Mac OS X 10.15.7 19H2
    darwin-x64, locale en)
    • Flutter version 1.24.0-8.0.pre.291 at
      /Users/pedromassango/dev/SDKs/flutter_master
    • Framework revision c1042314a9 (5 hours ago), 2020-11-18 01:38:02 -0500
    • Engine revision 35a0b9fe68
    • Dart version 2.12.0 (build 2.12.0-50.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/pedromassango/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2020.2.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 51.0.3
    • Dart plugin version 202.8070

[✓] VS Code (version 1.51.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

[✓] Connected device (4 available)
    • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86    • Android 11
      (API 30) (emulator)
    • macOS (desktop)             • macos         • darwin-x64     • Mac OS X
      10.15.7 19H2 darwin-x64
    • Web Server (web)            • web-server    • web-javascript • Flutter
      Tools
    • Chrome (web)                • chrome        • web-javascript • Google
      Chrome 86.0.4240.198

• No issues found!

@pedromassangocode pedromassangocode added a: text input Entering text in a text field or keyboard related problems found in release: 1.24 Found to occur in 1.24 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on c: regression It was better in the past than it is now customer: crowd Affects or could affect many people, though not necessarily a specific customer. labels Nov 18, 2020
@goderbauer
Copy link
Member

/cc @gspencergoog Didn't you recently talk about us deleting in two different places? Could this be related?

Also /cc @LongCatIsLooong @justinmc, who I think landed some changes in this area recently.

@gspencergoog
Copy link
Contributor

Yes, I think it is related. I'll take this one.

@gspencergoog gspencergoog self-assigned this Nov 18, 2020
@gspencergoog gspencergoog added P2 Important issues not at the top of the work list P1 High-priority issues at the top of the work list and removed P2 Important issues not at the top of the work list labels Nov 18, 2020
@pedromassangocode
Copy link

Cc @pcsosinski

@mehmetf mehmetf added P1 customer: money (g3) and removed P1 High-priority issues at the top of the work list labels Nov 19, 2020
@gspencergoog
Copy link
Contributor

I was able to see that what I suspected is true (we are handling the delete key twice now, once in the engine, once in the framework), but in fixing this, I uncovered some other race condition issues that I've been working on today.

I think can create a PR for fixing this problem, and a new bug for the race condition.

@JamMarHer
Copy link

I Love you people ❤️ I have been trying to figure out why this was happening to me for the past 2 hours!

@JamMarHer
Copy link

JamMarHer commented Nov 24, 2020

@pedromassangocode, @gspencergoog I have replicated a similar problem in the current flutter beta version (1.24.0-10.2.pre)

Same problem of deleting two characters at the same time

When an user types a combination of letters and numbers and then proceeds to press the delete key everything works as expected. The problem occurs when the user writes something that starts with a number and ends with a number.

This doesn't affect the web build.

Using the same code as the issue but without keyboardType :

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Test test test'),
        ),

        body: TextFormField());
  }
}
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Linux, locale en_US.UTF-8)
    • Flutter version 1.24.0-10.2.pre at /home/jam/Documents/Dev/flutter
    • Framework revision 022b333a08 (6 days ago), 2020-11-18 11:35:09 -0800
    • Engine revision 07c1eed46b
    • Dart version 2.12.0 (build 2.12.0-29.10.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/jam/Android/Sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_275-8u275-b01-0ubuntu1~20.10-b01)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] Connected device (2 available)
    • SM G981U (mobile) • RFCN20S1JTJ • android-arm64  • Android 10 (API 29)
    • Web Server (web)  • web-server  • web-javascript • Flutter Tools

@pedromassangocode
Copy link

Hi all,
This issue was already fixed and it eventually is on master channel.

@deepak786
Copy link

deepak786 commented Nov 26, 2020

same issue with the dev version Flutter 1.24.0-10.2.pre • channel dev • https://github.com/flutter/flutter.git

It deletes 2 chars from the text field with InputType text as well.

@Zfinix
Copy link

Zfinix commented Nov 27, 2020

Hi all,
This issue was already fixed and it eventually is on master channel.

Thanks!!

@sgehrman

This comment was marked as abuse.

@xihuny
Copy link

xihuny commented Dec 1, 2020

Why is this closed? Is it fixed? I am on beta and still facing this issue.

@gspencergoog
Copy link
Contributor

It was closed because it has been fixed on master. Changes on master will propagate to other branches as they proceed through the release process. See https://github.com/flutter/flutter/wiki/Flutter-build-release-channels

@pcsosinski
Copy link

FYI b4d4e30 will require a manual merge into flutter-1.22-candidate.12 cc @christopherfujino @gspencergoog

@pcsosinski pcsosinski modified the milestone: 1.26 - December 2020 Dec 10, 2020
@pcsosinski
Copy link

removing cp label as this was not affecting 1.22.

@jackgitsource
Copy link

same issue at 1.24.0-10.2.pre • channel beta

@ozc
Copy link

ozc commented Jan 13, 2021

This error also occurs for TextInputType.emailAddress

@justinmc
Copy link
Contributor

@jackgitsource Do you see this issue on master?

@jackgitsource
Copy link

@justinmc No, but beta version 1.25.0-8.2 solved it

@CoderJava
Copy link

Yeah. In beta version 1.25.0-8.2 solved it.

@pablo-johnson
Copy link

Is this issue fixed on master now?

@Qwampa
Copy link

Qwampa commented Mar 11, 2021

I am still getting this issue on Android. (stable 2.0.0)

@gspencergoog
Copy link
Contributor

@Qwampa I'm unable to reproduce this on stable 2.0.0. If this is still happening for you, please file a new issue with all the relevant information (output of flutter doctor -v, a simple reproduction code sample, etc.).

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
@flutter-triage-bot flutter-triage-bot bot added P0 Critical issues such as a build break or regression and removed P1 labels Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems c: regression It was better in the past than it is now customer: crowd Affects or could affect many people, though not necessarily a specific customer. customer: money (g3) found in release: 1.24 Found to occur in 1.24 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.