Commit b3a8ab87 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Fix omnibox focus bugs.

The omnibox' textfield is focused programmatically upon a button press.
This is no longer as straightforward as it was in single window. On iOS
13, tapping a textfield will make the corresponding window key if
necessary. Do this before becoming first responder.

Bug: 1072414, 1092824
Change-Id: I9b9df1d41c84a89f820c813f8fa2691897dc6076
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2312704
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarRobbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#791242}
parent 686c91be
......@@ -160,6 +160,7 @@ source_set("omnibox_internal") {
"//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/toolbar/public:feature_flags",
"//ios/chrome/browser/ui/util",
"//ios/chrome/browser/ui/util:multiwindow_util",
"//ios/chrome/common",
"//ios/chrome/common/ui/colors",
"//ios/chrome/common/ui/favicon",
......
......@@ -29,6 +29,7 @@
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_coordinator.h"
#include "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_ios.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/multi_window_support.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -128,6 +129,16 @@
- (void)focusOmnibox {
if (![self.textField isFirstResponder]) {
base::RecordAction(base::UserMetricsAction("MobileOmniboxFocused"));
// In multiwindow context, -becomeFirstRepsonder is not enough to get the
// keyboard input. The window will not automatically become key. Make it key
// manually. UITextField does this under the hood when tapped from
// -[UITextInteractionAssistant(UITextInteractionAssistant_Internal)
// setFirstResponderIfNecessaryActivatingSelection:]
if (IsMultiwindowSupported()) {
[self.textField.window makeKeyAndVisible];
}
[self.textField becomeFirstResponder];
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment