Repository navigation
Unable get focus of TextFormField - keyboard disappears #31827
Copy link
Copy link
Closed
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Description
Steps to Reproduce
Run this sample, click the body button "Tab 1" - the route will appear modally, you will see the keyboard attempt to show - then disappear.
You are then unable to get focus of any textfield, this never used to be an issue in my app until I upgraded flutter yesterday.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: Home(),
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoTabScaffold(
tabBar: CupertinoTabBar(
items: [
BottomNavigationBarItem(icon: Icon(Icons.message)),
BottomNavigationBarItem(icon: Icon(Icons.block)),
],
),
tabBuilder: (BuildContext context, int index) {
switch (index) {
case 0:
return CupertinoTabView(
builder: (context) => Page1(
title: "Tab 1",
),
);
break;
case 1:
return CupertinoTabView(
builder: (context) => Page1(
title: "Tab 2",
),
);
break;
}
},
);
}
}
class Page1 extends StatelessWidget {
final String title;
const Page1({Key key, this.title}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: FlatButton(
child: Text(title),
onPressed: () {
Navigator.of(context, rootNavigator: true).push(
MaterialPageRoute(
fullscreenDialog: true,
builder: (context) => CreateEditProductWizardPage(),
),
);
},
),
),
);
}
}
class CreateEditProductWizardPage extends StatefulWidget {
final bool editing;
const CreateEditProductWizardPage({Key key, this.editing = false})
: super(key: key);
@override
_CreateEditProductWizardPageState createState() =>
_CreateEditProductWizardPageState();
}
class _CreateEditProductWizardPageState
extends State<CreateEditProductWizardPage> {
static final _formKey = GlobalKey<FormState>();
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Form(
key: _formKey,
child: ListView(
children: [
TextFormField(
autofocus: true,
maxLines: 1,
),
Divider(
height: 0,
),
TextFormField(
maxLines: 2,
),
Divider(
height: 0,
),
TextFormField(
textInputAction: TextInputAction.done,
keyboardType: TextInputType.number,
),
Divider(
height: 0,
),
TextFormField(
textInputAction: TextInputAction.done,
keyboardType: TextInputType.number,
),
],
),
),
);
}
}
Logs
Nothing produced in the logs
[✓] Flutter (Channel master, v1.5.9-pre.66, on Mac OS X 10.14.4 18E226, locale en-ZA)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
[✓] Android Studio (version 3.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.2)
[✓] Connected device (1 available)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Activity
calvinmuller commentedon Apr 30, 2019
switching to flutter stable channel I can't reproduce this, so it's definitely been introduced recently.
HansMuller commentedon Apr 30, 2019
CC @gspencergoog
gspencergoog commentedon Apr 30, 2019
Thank you for the clear reproduction case!
I was able to easily reproduce this, and I believe I have a fix. I'll put together a PR shortly.
calvinmuller commentedon May 1, 2019
Thanks!
hgokulchavan commentedon Apr 14, 2021
I am having same issue. Seems like it is broken once again since Flutter 2.0. Please resolve this.
github-actions commentedon Aug 3, 2021
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 -vand a minimal reproduction of the issue.