Skip to content

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

@joachimvalente

Description

@joachimvalente

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!

Metadata

Metadata

Assignees

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: crowdAffects or could affect many people, though not necessarily a specific customer.customer: money (g3)found in release: 1.24Found to occur in 1.24frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions