[Android] - Tapping TextInput unfocuses it on Tablet emulator
Steps to reproduce
This happens on my Pixel C emulator but not my Pixel 6 emulator.
- Have the
TextInputdisplayed on the screen with nothing focused for at least 8 to 10 seconds. - Tap the
TextInput.
Expected results
TextInput focuses and remains focused.
Actual results
TextInput may briefly focus, soft keyboard opens, TextInput however does not remain focused. You can repeat the process as many times as you like, and it still happens.
Chuck a breakpoint on FocusNode.unfocus to see the stack trace. "TextInputClient.onConnectionClosed" is passed to Future<dynamic> _handleTextInputInvocation(MethodCall methodCall) in TextInput class from a platform channel.
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Text Input Example'),
),
body: const Center(
child: Padding(
padding: EdgeInsets.all(8.0),
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Enter something',
),
),
),
),
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
Here I wait for 8 or so seconds, then tap the TextInput, the soft keyboard opens for a few seconds while the TextInput remains unfocused, then I tap the TextInput a second time and it finally focuses.
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.16.8, on macOS 14.2.1 23C71 darwin-arm64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2023.2.2)
[✓] VS Code (version 1.86.1)
[✓] Connected device (7 available)
[✓] Network resources
• No issues found!
Hello @BenjiFarquhar. Thanks for filing this. I can't seem to reproduce this on my end both on an emulator device (Pixel 3a) and on a real Android device.
the soft keyboard opens for a few seconds
From the video shared, I can't see this behaviour, could this be an issue with where in the TextField onTap was received?
Testing with a Pixel C emulator, I have the behaviour below
https://github.com/flutter/flutter/assets/53122008/f8a7e11a-6722-4407-bafd-b4a1a7083b4c
Hi there, @dam-ease. Thanks for taking a look.
From the video shared, I can't see this behaviour
My video shows me waiting, then near the end, I tap the TextInput, and the soft keyboard goes up for a few seconds, but the TextInput remains unfocused; then I tap the TextInput a second time, and the TextInput focuses.
Can you wait 30 seconds with nothing focused, then tap the TextInput on your Pixel C emulator?
could this be an issue with where in the TextField onTap was received?
I don't understand what you mean.
Thanks for your response and patience. I tried running this again, can you please check if the video below captures the issue you are describing?
https://github.com/flutter/flutter/assets/53122008/9896d634-0a59-4a56-98ce-19401be8435b
@dam-ease No, in mine, the field becomes unfocused as soon as you tap it, but the keyboard opens. So, keyboard with no focus.
Yours was the opposite; the field is focused without a keyboard opening. So, focus with no keyboard.
Thanks for checking this out. I have tried producing this severally on my device but can only reproduce as above. Can you help with the full device information you are testing with?
@dam-ease Cheers. This might be an emulator issue, so it should be closed. I have just started using a different emulator to work around it. But here are the specs if you want to reproduce the issue on this emulator.
Thanks for sharing these.
Looking through, this is quite similar to the device I ran my tests on as well but with different API levels, my device is a Pixel C API 34.
This might be specific to this emulator, I'll label this for more insights per what you shared in original comment:
Chuck a breakpoint on FocusNode.unfocus to see the stack trace. "TextInputClient.onConnectionClosed" is passed to Future
_handleTextInputInvocation(MethodCall methodCall) in TextInput class from a platform channel.
You could also share any logs that pop on your end to provide more helpful insights into the issue.
CC @LongCatIsLooong from triage.
Issue is assigned to multiple teams (android, design). Please ensure the issue has only one team-* label at a time. Use fyi-* labels to have another team look at the issue without reassigning it.