Skip to content

Keyboard disappears in landscape orientation (phone) on the next TextField focus (Broken since Flutter v3.22.0) #148673

@JoanSchi

Description

@JoanSchi

Steps to reproduce

  • Use a phone in landscape orientation (I use pixel 3a, simulator)
  • Focus the first TextField
  • Go to the next TextField with keyboard or click on the next TextField.
  • Keyboard disappears, while in flutter 3.19.2 or before it worked fine.

Expected results

It is expected that the keyboard also stays visible if the focus goes to the next TextField when the phone is in in landscape orientation.

  • Flutter 3.22.0: Keyboard disappears
  • Flutter 3.19.2 Keyboard stays visible like expected (like the versions before)

Actual results

  • In landscape orientation the keyboard disappears when the next TextField gets focus.
  • You need to click the TextField again to show the keyboard.

Code sample

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: CustomScrollView(slivers: [
          SliverToBoxAdapter(
              child: Container(
            height: 500,
            color: Colors.amber,
          )),
          SliverToBoxAdapter(child: Builder(builder: (context) {
            return const Column(
              children: [
                SizedBox(
                  height: 72.0,
                  child: Row(children: [
                    Expanded(
                        child:
                            TextField(textInputAction: TextInputAction.next)),
                    SizedBox(
                      width: 8.0,
                    ),
                    Expanded(child: TextField()),
                  ]),
                ),
              ],
            );
          })),
          SliverToBoxAdapter(
              child: Container(
            height: 500,
            color: Colors.amber,
          )),
        ]));
  }
}

Screenshots or Video

Difference flutter 3.19.2 vs 3.22.0

Flutter 3.22.0, No Keyboard

image

Logs

Logs
No log at moment.

Flutter Doctor output

Doctor output Flutter 3.22.0
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.0, on Microsoft Windows [Version
    10.0.22631.3593], locale en-NL)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for
      more details.
[√] Chrome - develop for the web
[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 2023.3)
[√] VS Code (version 1.89.1)
[√] Connected device (5 available)
[√] Network resources
Doctor output Flutter 3.19.2
Success
PS C:\Repositories\flutter\test\keyboard_bug> flutter doctor   
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.2, on Microsoft Windows [Version
    10.0.22631.3593], locale en-NL)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.      
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for   
      more details.
[√] Chrome - develop for the web
[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 2023.3)
[√] VS Code (version 1.89.1)
[√] Connected device (5 available)
[√] Network resources

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowengineflutter/engine related. See also e: labels.f: focusFocus traversal, gaining or losing focusfound in release: 3.22Found to occur in 3.22has 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 teamtriaged-text-inputTriaged 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