Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Android] Reset IME state in TextInputPlugin.clearTextInputClient #49829

Conversation

bleroux
Copy link
Contributor

@bleroux bleroux commented Jan 17, 2024

Description

This PR calls Android API InputMethodManager.restartInput to reset IMEs internal states. Otherwise some IMEs (Gboard for instance) keep reacting based on the previous input configuration until a new configuration is set.

Related Issue

Fixes flutter/flutter#70546.
Fixes flutter/flutter#51478

Tests

Adds 1 test.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thanks for tracking this down.

One thing to note is that restarting the IME will affect composing text if it happens while composing. However since this change is in clearTextInputClient it shouldn't affect composing, so this should be fine.

@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 18, 2024
@auto-submit auto-submit bot merged commit 873449c into flutter:main Jan 18, 2024
@bleroux bleroux deleted the android_reset_IME_state_in_clearTextInputClient branch January 18, 2024 06:52
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 18, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 18, 2024
…141759)

flutter/engine@bfdc0c5...873449c

2024-01-18 [email protected] [Android] Reset IME state in TextInputPlugin.clearTextInputClient (flutter/engine#49829)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@bleroux
Copy link
Contributor Author

bleroux commented Jun 18, 2024

@justinmc WDYT of reverting this change in order to fix the following regression: flutter/flutter#148673?

I can repro this even on Android API 30 so this is not similar to flutter/flutter#148117.

We can probably find another way to make it possible to call InputMethodManager.restartInput. Here it was done automatically in clearTextInputClient but it seems to be a problem when this is called while navigating to another field.

Another option would be to call it only for some particular TextInputAction (for instance TextInputAction.done).

@justinmc
Copy link
Contributor

Discussed offline, but I'm hoping we don't have to revert this since the two bugs fixed here are arguably worse than flutter/flutter#148673.

auto-submit bot pushed a commit that referenced this pull request Jul 18, 2024
## Description

This PR restricts the call to `restartInput` which was added in #49829.
The restart is called when input action is null, DONE, or NONE.

## Related Issue

Fixes flutter/flutter#148673.

## Tests

Updates 1 test, adds 3 tests.
auto-submit bot pushed a commit that referenced this pull request Aug 1, 2024
## Description

This PR reverts two commits #49829 and #53662.

The main change was in #49829. #53662 was a follow-up to mitigate the impact of #49829.

## Related Issue

Fixes flutter/flutter#148530
Fixes flutter/flutter#152620

Reopens flutter/flutter#70546.
Reopens flutter/flutter#51478
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RawKeyboardListener triggers soft keyboard on Android Flutter OnScreen Keyboard opens on physical key press
2 participants