New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 636237 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Nov 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

webview should not hide keyboard when losing focus

Project Member Reported by changwan@chromium.org, Aug 10 2016

Issue description


STEPS TO REPRODUCE:
1. Open Compose in Inbox
2. Set focus on the Body
3. Move focus on the Subject

EXPECTED RESULTS:
The soft keyboard stays open

OBSERVED RESULTS:
Sometimes, the soft keyboard tries to close, then open right back up.


Originally filed as b/29402905


We may need to hide keyboard in certain situations for Chrome,
so it should be carefully removed.

Also note that when moving focus from WebView to a focusable button,
we won't hide keyboard. This is a small Android quirk for which I couldn't change the current behavior, but yes, it's more important to avoid blinking for normal cases.

 
Cc: -yabinh@chromium.org changwan@chromium.org
Owner: yabinh@chromium.org
reassigning to yabinh@

Comment 2 by aelias@chromium.org, Aug 19 2016

Labels: ReleaseBlock-Stable
This bug has a label marking it high priority on http://b/29402905 , so let's get it into M54.  yabinh@, please look into this ahead of your less urgent tasks.

Comment 3 by yabinh@chromium.org, Aug 19 2016

If we keep keyboard, we will get 1 test failure:
ContentViewCoreFocusTest#testHideImeOnLosingFocus

In fact, the only purpose of the failed test is to confirm that IME window should be hidden from the content view when the content view loses its focus.

I think we should change the failed test if we consider it a bug.
Please check #0. This is an expected behavior on Chrome that we need to fix.

Comment 5 by aelias@chromium.org, Aug 22 2016

The scenario in #0 is transferring focus from a WebView textbox to an Android native textbox.  We would like to preserve the keyboard showing in that case.   But in other cases where the WebView textbox simply lost focus with no replacement, we of course still want to hide the keyboard (which is what testHideImeOnLosingFocus is testing).

I'm not sure exactly how to detect the difference from the WebView.  I think we could check https://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html#isActive() at an appropriate time and only hide if it returns false.

The main difficulty would be to determine the appropriate time.  As an initial prototype to test viability, a fixed 500ms timeout would probably work.  But I'd rather not land that if at all possible.  We should take a close look at all possible listeners and events in the Android APIs we could wait on instead of a fixed timer, I haven't found a good one yet but there's probably something.

Comment 6 by aelias@chromium.org, Aug 23 2016

I realized TextViews themselves must have the same problem.  Looking at https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/TextView.java , there is quite a lot of logic around hiding/focus. We should take the time to understand how it avoids the same bug when going from TextView -> TextView or TextView -> WebView, then apply the same approach.
In normal cases when View focus moves from focusable to non-focusable components, Android's IMM automatically dismisses the keyboard (except for some small corner cases). The current mechanism in ImeAdapter is actually only needed for Chrome, if I remember correctly.

When I wrote testHideImeOnLosingFocus I had the following test case in mind:

1. Launch a Chrome on tablet.
2. Activate input on one tab.
3. Open another tab.
--> The input should be hidden.

Chrome should hide keyboard in this case because Android View focus hasn't changed.

There may be some other cases affected by the behavior change, but I haven't fully tested them myself.
Re #6, that's a good point. I think we should also be extra careful about navigation cases.

Comment 9 by aelias@chromium.org, Aug 23 2016

Cc: jinsuk...@chromium.org siev...@chromium.org
OK, it sounds like we could simply not run our special ImeAdapter hiding logic at all if we're in a WebView, which is easier than I thought.

Perhaps to more elegantly solve #7 we should be switching to having a different Android View per tab instead of reusing the same one so that things like this Just Work?  This is tied to some of the browser refactoring ideas.
Labels: -M-54 M-55
Punting to 55 because the launch train for http://b/29402905 is delayed due to missing spellcheck support.
FYI, b/31975065 seems also related to this behavior.
Also, b/32373760 seems to be the same issue.
Project Member

Comment 13 by bugdroid1@chromium.org, Nov 3 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/66d5ae12299e85269251cd655d46a7b5710b7c80

commit 66d5ae12299e85269251cd655d46a7b5710b7c80
Author: yabinh <yabinh@chromium.org>
Date: Thu Nov 03 05:49:32 2016

Make WebView keep keyboard when losing focus

WebView should not hide keyboard when losing focus. As for Chrome, it
should keep current behavior. These cases include when the ContentView is
hidden (closing current tab, opening a new tab, switching to an existing
tab), and when imeAdapter is attached to its native counterpart(navigation).
Note that this CL will change one behavior of Chrome: keyboard will not be
hidden when focus moves from ContentView to UrlBar.

BUG= 636237 

Review-Url: https://codereview.chromium.org/2290133002
Cr-Commit-Position: refs/heads/master@{#429531}

[modify] https://crrev.com/66d5ae12299e85269251cd655d46a7b5710b7c80/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java
[modify] https://crrev.com/66d5ae12299e85269251cd655d46a7b5710b7c80/chrome/test/data/android/tabstest/tabs_test.html
[modify] https://crrev.com/66d5ae12299e85269251cd655d46a7b5710b7c80/content/public/android/BUILD.gn
[modify] https://crrev.com/66d5ae12299e85269251cd655d46a7b5710b7c80/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
[delete] https://crrev.com/92cc84f200b7839f220a26633f1ba8983ea361aa/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreFocusTest.java
[modify] https://crrev.com/66d5ae12299e85269251cd655d46a7b5710b7c80/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
[modify] https://crrev.com/66d5ae12299e85269251cd655d46a7b5710b7c80/content/test/data/android/input/input_forms.html

Labels: Merge-Request-55

Comment 15 by dimu@chromium.org, Nov 8 2016

Labels: -Merge-Request-55 Merge-Approved-55 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M55 (branch: 2883)
Project Member

Comment 16 by bugdroid1@chromium.org, Nov 9 2016

Labels: -merge-approved-55 merge-merged-2883
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/cd665343ae016f7aa817553648a6620186a65d50

commit cd665343ae016f7aa817553648a6620186a65d50
Author: Alexandre Elias <aelias@chromium.org>
Date: Tue Nov 08 23:59:56 2016

Make WebView keep keyboard when losing focus

WebView should not hide keyboard when losing focus. As for Chrome, it
should keep current behavior. These cases include when the ContentView is
hidden (closing current tab, opening a new tab, switching to an existing
tab), and when imeAdapter is attached to its native counterpart(navigation).
Note that this CL will change one behavior of Chrome: keyboard will not be
hidden when focus moves from ContentView to UrlBar.

BUG= 636237 

Review URL: https://codereview.chromium.org/2485573008 .

Review-Url: https://codereview.chromium.org/2290133002
Cr-Original-Commit-Position: refs/heads/master@{#429531}
Cr-Commit-Position: refs/branch-heads/2883@{#499}
Cr-Branched-From: 614d31daee2f61b0180df403a8ad43f20b9f6dd7-refs/heads/master@{#423768}

[modify] https://crrev.com/cd665343ae016f7aa817553648a6620186a65d50/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java
[modify] https://crrev.com/cd665343ae016f7aa817553648a6620186a65d50/chrome/test/data/android/tabstest/tabs_test.html
[modify] https://crrev.com/cd665343ae016f7aa817553648a6620186a65d50/content/public/android/BUILD.gn
[modify] https://crrev.com/cd665343ae016f7aa817553648a6620186a65d50/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
[delete] https://crrev.com/69cba6427c6cc679855739eda4e3311473cfa5ba/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreFocusTest.java
[modify] https://crrev.com/cd665343ae016f7aa817553648a6620186a65d50/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
[modify] https://crrev.com/cd665343ae016f7aa817553648a6620186a65d50/content/test/data/android/input/input_forms.html

Status: Fixed (was: Assigned)
Project Member

Comment 18 by bugdroid1@chromium.org, Nov 9 2016

Project Member

Comment 19 by bugdroid1@chromium.org, Nov 10 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/af689b896e2307286cc6b82b2728fe16b483f897

commit af689b896e2307286cc6b82b2728fe16b483f897
Author: Alexandre Elias <aelias@chromium.org>
Date: Thu Nov 10 06:39:58 2016

Make WebView keep keyboard when losing focus (2nd cherrypick)

WebView should not hide keyboard when losing focus. As for Chrome, it
should keep current behavior. These cases include when the ContentView is
hidden (closing current tab, opening a new tab, switching to an existing
tab), and when imeAdapter is attached to its native counterpart(navigation).
Note that this CL will change one behavior of Chrome: keyboard will not be
hidden when focus moves from ContentView to UrlBar.

BUG= 636237 

Review URL: https://codereview.chromium.org/2492763002 .

Review-Url: https://codereview.chromium.org/2290133002
Cr-Original-Commit-Position: refs/heads/master@{#429531}
Cr-Commit-Position: refs/branch-heads/2883@{#517}
Cr-Branched-From: 614d31daee2f61b0180df403a8ad43f20b9f6dd7-refs/heads/master@{#423768}

[modify] https://crrev.com/af689b896e2307286cc6b82b2728fe16b483f897/content/public/android/BUILD.gn
[modify] https://crrev.com/af689b896e2307286cc6b82b2728fe16b483f897/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
[delete] https://crrev.com/6e2d4b414c441a235ba94d08cbbca7ff2d6b9d2c/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreFocusTest.java

verified with Galaxy S7 Verizon / MMB29M vs latest M56
Status: Verified (was: Fixed)
Verified on Samsung Galaxy S6 Edge(SM-G925T)/MMB29K, Webview: 55.0.2883.53 

Sign in to add a comment