Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java |
index b34157c0244179616c4050baa283a3a5794f0335..5dd539b41b8c70c30f94cba53db9474aa5c77fa7 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/OverlayPanel.java |
@@ -297,8 +297,9 @@ public class OverlayPanel extends OverlayPanelAnimation implements ActivityState |
} |
/** |
- * Set the visibility of the base page text selection controls. |
- * TODO(mdjones): This should be replaced be focusing the panel's ContentViewCore. |
+ * Set the visibility of the base page text selection controls. This will also attempt to |
+ * remove focus from the base page to clear any open controls. |
+ * TODO(mdjones): This should be replaced with focusing the panel's ContentViewCore. |
* @param visible If the text controls are visible. |
*/ |
protected void setBasePageTextControlsVisibility(boolean visible) { |
@@ -308,10 +309,16 @@ public class OverlayPanel extends OverlayPanelAnimation implements ActivityState |
if (baseContentView == null) return; |
// If the panel does not have focus or isn't open, return. |
- if (isPanelOpened() && mDidClearTextControls && visible) return; |
- if (!isPanelOpened() && !mDidClearTextControls && !visible) return; |
+ if (isPanelOpened() && mDidClearTextControls && !visible) return; |
+ if (!isPanelOpened() && !mDidClearTextControls && visible) return; |
mDidClearTextControls = !visible; |
+ |
+ if (!visible) { |
+ baseContentView.preserveSelectionOnNextLossOfFocus(); |
+ baseContentView.getContainerView().clearFocus(); |
+ } |
+ |
baseContentView.updateTextSelectionUI(visible); |
} |