Skip to content

UndoHistoryController does not function properly in languages like Japanese where characters are confirmed when typed. #134398

@hatano0x06

Description

@hatano0x06

Is there an existing issue for this?

Steps to reproduce

  1. Input "あ"
  2. Confirm text
  3. Input "い"
  4. Confirm text
  5. Press undo
  6. Press undo again

Expected results

textformfield is empty

Actual results

"あ" remains in textformfield and "い" blinks when the undo button is pressed.

Code sample

Code sample
class SamplePage extends StatefulWidget {

  SamplePage(): super();

  @override
  SamplePageState createState() => SamplePageState();
}

class SamplePageState extends State<SamplePage> with WidgetsBindingObserver {

  final UndoHistoryController _undoController = UndoHistoryController();

  @override
  void initState() {
    super.initState();  
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          const SizedBox(height: 150,),
          TextFormField(
            maxLines:null, 
            undoController: _undoController,
          ),
          ElevatedButton(
            onPressed: (){
              _undoController.undo();
              setState(() { });
            }, 
            child: const Text("undo")
          )
        ]
      ),
    );

  }

}

Screenshots or Video

Screenshots / Video demonstration

untitled

Logs

Logs
It's too long to post, so if you need it, please leave a comment.

Flutter Doctor output

Doctor output
[√] Flutter (Channel master, 3.14.0-14.0.pre.210, on Microsoft Windows [Version 10.0.22621.2215], locale ja-JP)
    • Flutter version 3.14.0-14.0.pre.210 on channel master at C:\Users\81708\Desktop\develop\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 0d9ea62756 (7 hours ago), 2023-09-10 18:34:24 -0400
    • Engine revision 04d836f695
    • Dart version 3.2.0 (build 3.2.0-134.0.dev)
    • DevTools version 2.27.0

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\81708\AppData\Local\Android\sdk
    • Platform android-33, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • 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 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.82.0)
    • VS Code at C:\Users\81708\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.72.0

[√] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.2215]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 116.0.5845.180
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 116.0.1938.76

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.found in release: 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions