Skip to content

Keyboard dismisses in landscape orientation on changing TextFields #152620

@Roonil

Description

@Roonil

Steps to reproduce

  1. Create a Flutter app (with latest stable, beta or master channels)
  2. Instantiate multiple TextFields or TextFormFields
  3. Launch app on Android (physical device/emulator) and set orientation to landscape
  4. Change focus to another TextField by tapping on it or by using the TextInput.next InputAction

Expected results

Keyboard should stay open as long as the TextFields are tapped onto. Changing focus from one TextField to another should not dismiss the keyboard

Actual results

Upon changing the TextFields, the Keyboard dismisses unexpectedly. This does not happen on Flutter 3.19.2, or when the orientation is portrait mode. Tested on OnePlus 11R Physical Device on Android 14, and Android 13 & 15 emulators. Reproducible on the latest stable, beta and master channels.

Also noteworthy, when the keyboard is dismissed this way, THIS gets printed to the debug console:

I/ImeTracker( 4132): com.example.flutter_application_2:7a8cf546: onRequestHide at ORIGIN_CLIENT reason HIDE_SOFT_INPUT_ON_ANIMATION_STATE_CHANGED fromUser false
I/ImeTracker( 4132): com.google.android.inputmethod.latin:a58bc318: onHidden

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: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[TextField(), TextField()],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
353456781-0aac43ed-6dcd-472d-be84-38e0d5724a04.mp4

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.3, on Kali GNU/Linux Rolling 6.8.11-amd64, locale en_IN)
    • Flutter version 3.22.3 on channel stable at /home/r00n1l/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (13 days ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /home/r00n1l/Android/Sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2024.1)
    • Android Studio at /opt/android-studio
    • 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.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.91.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.92.0

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 15 (API 35) (emulator)
    • Linux (desktop)              • linux         • linux-x64      • Kali GNU/Linux Rolling 6.8.11-amd64
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 126.0.6478.126

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

• No issues found!

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowf: focusFocus traversal, gaining or losing focusfound in release: 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions