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

Undo/Redo history disappears on Japanese keyboard #130881

Closed
2 tasks done
toshiaki-h opened this issue Jul 19, 2023 · 4 comments · Fixed by #138674
Closed
2 tasks done

Undo/Redo history disappears on Japanese keyboard #130881

toshiaki-h opened this issue Jul 19, 2023 · 4 comments · Fixed by #138674
Assignees
Labels
a: internationalization Supporting other languages or locales. (aka i18n) a: text input Entering text in a text field or keyboard related problems found in release: 3.10 Found to occur in 3.10 found in release: 3.13 Found to occur in 3.13 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@toshiaki-h
Copy link

Is there an existing issue for this?

Steps to reproduce

  1. Type 2022 on Japanese keyboard.
  2. Tap the Undo button
  3. You can see that the Redo button cannot be tapped.

Expected results

Undo/Redo works correctly when using a Japanese keyboard.
In this case, Redo can be tapped.

Actual results

The Redo button is enabled for a moment, but becomes disable immediately.

Code sample

Code sample
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Undo/Redo Test',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Undo/Redo Test'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late final _undoController = UndoHistoryController();

  late final _editingController = TextEditingController();

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

  @override
  void dispose() {
    _undoController.dispose();
    _editingController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(children: [
            TextField(
              controller: _editingController,
              undoController: _undoController,
            ),
            ValueListenableBuilder(
              valueListenable: _undoController,
              builder: (context, value, child) {
                return Row(
                  children: [
                    IconButton(
                      icon: const Icon(Icons.undo),
                      onPressed: value.canUndo ? _undoController.undo : null,
                    ),
                    IconButton(
                      icon: const Icon(Icons.redo),
                      onPressed: value.canRedo ? _undoController.redo : null,
                    ),
                  ],
                );
              },
            )
          ]),
        ));
  }
}

Screenshots or Video

Screenshots / Video demonstration
screen-20230719-211736.2.mp4

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d darwin-x64, locale ja-JP)
    • Flutter version 3.10.6 on channel stable at /Users/aki/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (7 days ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/aki/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2022.2)
    • 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 17.0.6+0-17.0.6b802.4-9586694)

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

[✓] Connected device (3 available)
    • Pixel 7 (mobile) • adb-29151FDH200FTQ-ysEEH4._adb-tls-connect._tcp. • android-arm64  • Android 13 (API 33)
    • macOS (desktop)  • macos                                            • darwin-x64     • macOS 13.4.1 22F770820d darwin-x64
    • Chrome (web)     • chrome                                           • web-javascript • Google Chrome 114.0.5735.198

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

• No issues found!
@dam-ease dam-ease added the in triage Presently being triaged by the triage team label Jul 19, 2023
@dam-ease
Copy link

Hi @toshiaki-h. Thanks for filing this issue. I am able to reproduce this issue on the latest master and stable channels. This issue seems to be specific to Japanese Keyboards as I can't seem to produce on English, Russian and Arabic. Also, I'm only able to reproduce this on Android devices and works fine on iOS.

Android iOS
untitled.webm
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-07-19.at.14.37.58.mp4
untitled.webm
flutter doctor -v

[✓] Flutter (Channel stable, 3.10.6, on macOS 13.4 22F66 darwin-arm64, locale
    en-NG)
    • Flutter version 3.10.6 on channel stable at /Users/dammya/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (7 days ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version
    32.1.0-rc1)
    • Android SDK at /Users/dammya/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • ANDROID_HOME = /Users/dammya/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2021.2)
    • 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
      11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

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

[✓] Connected device (4 available)
    • sdk gphone arm64 (mobile) • emulator-5554                        •
      android-arm64  • Android 11 (API 30) (emulator)
    • iPhone 14 Pro (mobile)    • DCF2031A-7EA9-42FF-8CD4-D4584F3E7A6D • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)           • macos                                •
      darwin-arm64   • macOS 13.4 22F66 darwin-arm64
    • Chrome (web)              • chrome                               •
      web-javascript • Google Chrome 114.0.5735.198

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

• No issues found!
[✓] Flutter (Channel master, 3.13.0-6.0.pre.34, on macOS 13.4 22F66 darwin-arm64, locale en-NG)
    • Flutter version 3.13.0-6.0.pre.34 on channel master at /Users/dammya/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 37ed50ac34 (2 hours ago), 2023-07-19 05:54:05 -0400
    • Engine revision 09389b16d6
    • Dart version 3.1.0 (build 3.1.0-325.0.dev)
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/dammya/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • ANDROID_HOME = /Users/dammya/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2021.2)
    • 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 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

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

[✓] Connected device (4 available)
    • sdk gphone arm64 (mobile) • emulator-5554                        • android-arm64  • Android 11 (API 30) (emulator)
    • iPhone 14 Pro (mobile)    • DCF2031A-7EA9-42FF-8CD4-D4584F3E7A6D • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)           • macos                                • darwin-arm64   • macOS 13.4 22F66 darwin-arm64
    • Chrome (web)              • chrome                               • web-javascript • Google Chrome 114.0.5735.198

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

• No issues found!

@dam-ease dam-ease added platform-android Android applications specifically a: internationalization Supporting other languages or locales. (aka i18n) has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.10 Found to occur in 3.10 team-android Owned by Android platform team found in release: 3.13 Found to occur in 3.13 and removed in triage Presently being triaged by the triage team labels Jul 19, 2023
@toshiaki-h
Copy link
Author

Hi @dam-ease. Thank you for confirming the reproduction.
I also checked it on iOS. It certainly seems to occur with the Android Japanese keyboard.
I use Gboard as my keyboard.

@reidbaker reidbaker added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. fyi-framework For the attention of Framework team and removed team-android Owned by Android platform team labels Aug 24, 2023
@darshankawar darshankawar added the team-framework Owned by Framework team label Aug 30, 2023
@Piinks Piinks added a: desktop Running on desktop triaged-framework Triaged by Framework team labels Aug 30, 2023
@Piinks Piinks changed the title Undo/Redo history disappears Undo/Redo history disappears on Japanese keyboard Aug 30, 2023
@Piinks Piinks added team-desktop and removed team-framework Owned by Framework team labels Aug 30, 2023
@flutter-triage-bot flutter-triage-bot bot removed fyi-framework For the attention of Framework team triaged-framework Triaged by Framework team labels Aug 30, 2023
@gspencergoog gspencergoog added fyi-android For the attention of Android platform team team-framework Owned by Framework team and removed a: desktop Running on desktop team-desktop labels Aug 31, 2023
@gspencergoog
Copy link
Contributor

This appears to be specific to Android (which is not desktop), and probably is somewhere in the vicinity of text input or the Android embedder. (Desktop Triage)

@camsim99 camsim99 added the triaged-android Triaged by Android platform team label Sep 7, 2023
@flutter-triage-bot flutter-triage-bot bot removed fyi-android For the attention of Android platform team triaged-android Triaged by Android platform team labels Sep 7, 2023
@goderbauer goderbauer added P2 Important issues not at the top of the work list triaged-framework Triaged by Framework team labels Sep 12, 2023
@Renzo-Olivares Renzo-Olivares self-assigned this Nov 18, 2023
auto-submit bot pushed a commit that referenced this issue Nov 30, 2023
This change adds a feature to `UndoHistory` that allows the user to modify the value being pushed onto the undo stack.

This is used by the framework to ignore the composing region when pushing history entries to the Undo stack on Android. This is so an undo does not trigger an input connection restart by the Android TextInputPlugin, which occurs when the framework changes the composing region. This is also the native platform behavior observed in Google Keep app on Android, where doing an undo during composing reverts to the previous state but with composing inactive and a subsequent redo does not bring back the composing region.

Fixes #130881
Partial fix for #134398
@dam-ease dam-ease added the r: fixed Issue is closed as already fixed in a newer version label Dec 11, 2023
Copy link

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 Dec 25, 2023
caseycrogers pushed a commit to caseycrogers/flutter that referenced this issue Dec 29, 2023
This change adds a feature to `UndoHistory` that allows the user to modify the value being pushed onto the undo stack.

This is used by the framework to ignore the composing region when pushing history entries to the Undo stack on Android. This is so an undo does not trigger an input connection restart by the Android TextInputPlugin, which occurs when the framework changes the composing region. This is also the native platform behavior observed in Google Keep app on Android, where doing an undo during composing reverts to the previous state but with composing inactive and a subsequent redo does not bring back the composing region.

Fixes flutter#130881
Partial fix for flutter#134398
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: internationalization Supporting other languages or locales. (aka i18n) a: text input Entering text in a text field or keyboard related problems found in release: 3.10 Found to occur in 3.10 found in release: 3.13 Found to occur in 3.13 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants