Open devforey opened 4 years ago
Hi @devforey something looks off, trying to repro your case doesn't even trigger the keyboard
I reproduced this, it does seem like something we should fix. I confirmed that native Android does open the keyboard again when you switch back. Flutter on iOS keeps the keyboard up immediately when you switch back.
I can reproduce this with stable 3.0.1 and the master 3.1.0
Flutter | Native Android |
---|---|
The bug bugz me as well. Besides the behaviour of not preserving open keyboard state between hide/resume is not consistent with other popular Android apps (e.g. Chrome, YouTube).
Having the same problem. Also, if I lock the screen when keyboard is shown, then unlock the phone, the keyboard stays but its input in not appearing in the text view. I have to re-open the keyboard or tap the text view for keyboard to work again.
Still having same problem using latest flutter version:
[✓] Flutter (Channel stable, 3.16.0, on macOS 14.1.1 23B81 darwin-arm64) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.84.2)
Any updates on this? still getting the same problem with the latest flutter version. Keyboard keeps dismissing on app resume.
@LongCatIsLooong This seems to be happening when autofocus
isn't true, too (see https://github.com/flutter/flutter/issues/137667#issuecomment-2108953924), but I see that the autofocus
documentation mentions that it controls when the keyboard is shown, so can I confirm that this is by design?
This issue doesn't occur on iOS, only Android, and I believe is unrelated to autofocus.
This issue [...] I believe is unrelated to autofocus.
Yes, this is what I'm trying to confirm. Based on the Android documentation it does not seem that this would occur on native Android by default, but I'm wondering if the idea was that autofocus
has to be true to enable that default behavior.
My initial thought here though is that I wonder if some of the conditions described in https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibility#ShowReliably are not being met when we call showSoftInput
(source). This assumes that this is getting called when the app resumes, so we should first confirm that it is getting called and if so, try a more reliably method.
I don't think the framework sends a show
message to the Android text input plugin when the app is brought back to the foreground. The EditableText
widget doesn't respond to app lifecycle changes itself IIRC, and on Android app lifecycle changes do not trigger in-app focus changes:
https://github.com/flutter/flutter/blob/b98ffdc46761d3f45f95bfc1cb66c6872e9328d6/packages/flutter/lib/src/widgets/focus_manager.dart#L1524-L1533
Based on the Android documentation it does not seem that this would occur on native Android by default
The documentation only says the keyboard may be dismissed when the app goes to the background, but it doesn't seem to mention the behavior when the app resumes? I tried this in some Android apps they do seem to show soft input on activity resume, but I failed to find relevant code in TextView.java
/EditText.java
that does that. We should be able to confirm the "default" behavior by creating an Android app with an EditText
I guess.
This issue is assigned to @LongCatIsLooong but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!
Just reported this an issue at #155592, it turns out it was the same report as #147497.
I want to highlight that the original description of the bug put the app in the background. However, the keyboard unfocus behaviour can be reproduced much more easily. Simply dragging down the notifications panel and bringing it back up causes the keyboard to lose focus.
I can reproduce the keyboard loss due to a notifications panel drag on a Samsung Galaxy A25 5G running Android 14. On a Pixel 1 running Android 10, notifications drag does not cause the text field to lose focus.
I also think this issue could be about two things:
autofocus:
property)autofocus: true
configuration, it should receive the focus if the app is resumed.I think the case 1. is the main problem and the 2. way to interpret the problem was mostly brought about as a result of the original bug report mentioning autofocus
.
Assuming problem 1... On native Android I've experienced different behaviours: Pixel 1:
Samsung Galaxy A25 5G:
When running a Flutter app:
If a text field is focused and has a keyboard and the app is put in the background, the keyboard is not shown again when the app is resumed. I've observed this behaviour on Instagram, Messenger...
Notice the same behaviour on Pixel 7 & 8 using the Messenger app.
However, on Telegram it works differently and as I would expect it: If a text field is focused and has a keyboard and the app is put in the background, the keyboard is shown again when the app is resumed.
Any news with that bug?
Steps to Reproduce
TextField
withautofocus: true
Expected results: TextField should be focused and the keyboard should be opened.
Actual results: TextField is showing but the keyboard is not opened.