Open gnprice opened 11 hours ago
I think there are basically two strategies for solving this:
Figure out why navigating back opens the keyboard, and make it not do so.
The keyboard's appearing has to fundamentally be under our control, because it can be triggered by the "back"/"close" button in an app bar. That's a gesture that's meaningful only to the app and the Flutter framework — the OS doesn't know anything about it — so the framework must be doing something that signals the keyboard to appear, presumably from the navigator code.
OTOH in situations where a text field is focused and the keyboard is open, it might be annoying if navigating to some other page and back caused the keyboard to go away.
When the user dismisses the keyboard, unfocus the text field too.
I'm not sure if there's a clean way to make this happen — to notice specifically when the keyboard gets dismissed. A crude hack that'd mostly work would be to watch for changes to our viewport that look like the keyboard getting dismissed.
(A third strategy I don't intend to use: we could pass ScrollViewKeyboardDismissBehavior.onDrag
to the message list's scroll view, so that trying to scroll causes the keyboard to vanish and the text input to lose focus. See reasoning in chat for why this would be annoying behavior.)
The second strategy is what Discord does. (I don't know if they've found a clean way to do it or are using that crude hack.)
The first strategy is what Facebook Messenger does and what Slack does.
Repro:
This is a variant of #1097, and I assume it has the same root cause: after dismissing the keyboard in step 3 above, the text field is still focused. When it occurs, this symptom is much more obtrusive and annoying.
I learned about this symptom the other day from a longtime Zulip user who was trying out the Flutter beta app; he ran into this within the first few minutes.