[iOS] Fix Find UI resigning first responder when tab grid closes on iPad
When Native Find in Page (with the iOS 16 Find panel) is triggered on iPhone, the Find navigator view becomes first responder in a separate window i.e. not the key window. On iPad however, the Find navigator view is not present in the current window scene and does not seem accessible so there is no way to check if it should act as the first responder. This is a problem because when the tab switcher is dismissed, the tab grid coordinator will only look for a first responder in the current window scene. This CL changes how the tab grid coordinator decides on a new first responder once it is done dismissing the tab switcher and presenting a tab view controller on top of it. Specifically, instead of simply setting the current BVC as first responder if no first responder has been found in the current window scene, the tab grid coordinator also checks if the current web state (the one being presented) has an active Find UI and if Find in Page uses the system Find panel. If so, then the Find navigator should already be presented at this point and so it should remain first responder. As a result, if the Find UI is active in the current web state, instead of ignoring it and setting the BVC as first responder, the Find panel will now remain first responder. Fixed: 1442502 Change-Id: Ifd581709fe63a40df68abc847dfd441ef7bc106c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4526023 Commit-Queue: Quentin Pubert <qpubert@google.com> Reviewed-by: Mark Cogan <marq@chromium.org> Cr-Commit-Position: refs/heads/main@{#1144573}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
cd1a8a5ecc
commit
3544a86caa
ios/chrome/browser/ui/tab_switcher/tab_grid
@ -33,6 +33,7 @@ source_set("tab_grid") {
|
||||
"//ios/chrome/browser/bring_android_tabs:features",
|
||||
"//ios/chrome/browser/commerce:commerce",
|
||||
"//ios/chrome/browser/drag_and_drop",
|
||||
"//ios/chrome/browser/find_in_page",
|
||||
"//ios/chrome/browser/flags:system_flags",
|
||||
"//ios/chrome/browser/main",
|
||||
"//ios/chrome/browser/policy:policy_util",
|
||||
@ -98,6 +99,7 @@ source_set("tab_grid") {
|
||||
"//ios/chrome/browser/web_state_list:agents",
|
||||
"//ios/chrome/browser/web_state_list/web_usage_enabler",
|
||||
"//ios/chrome/browser/window_activities",
|
||||
"//ios/public/provider/chrome/browser/find_in_page:find_in_page_api",
|
||||
"//ios/web",
|
||||
"//ui/base",
|
||||
"//ui/gfx",
|
||||
|
@ -18,6 +18,7 @@
|
||||
#import "ios/chrome/browser/bring_android_tabs/bring_android_tabs_to_ios_service.h"
|
||||
#import "ios/chrome/browser/bring_android_tabs/bring_android_tabs_to_ios_service_factory.h"
|
||||
#import "ios/chrome/browser/bring_android_tabs/features.h"
|
||||
#import "ios/chrome/browser/find_in_page/find_tab_helper.h"
|
||||
#import "ios/chrome/browser/main/browser_util.h"
|
||||
#import "ios/chrome/browser/policy/policy_util.h"
|
||||
#import "ios/chrome/browser/prefs/pref_names.h"
|
||||
@ -90,12 +91,39 @@
|
||||
#import "ios/chrome/browser/url_loading/url_loading_browser_agent.h"
|
||||
#import "ios/chrome/browser/url_loading/url_loading_params.h"
|
||||
#import "ios/chrome/grit/ios_strings.h"
|
||||
#import "ios/public/provider/chrome/browser/find_in_page/find_in_page_api.h"
|
||||
#import "ui/base/l10n/l10n_util.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// If Find in Page uses the system Find panel and if the Find UI is marked as
|
||||
// active in the current web state of `browser`, this returns true. Otherwise,
|
||||
// returns false.
|
||||
bool FindNavigatorShouldBePresentedInBrowser(Browser* browser) {
|
||||
if (!ios::provider::IsNativeFindInPageWithSystemFindPanel()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
web::WebState* currentWebState =
|
||||
browser->GetWebStateList()->GetActiveWebState();
|
||||
if (!currentWebState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FindTabHelper* helper = FindTabHelper::FromWebState(currentWebState);
|
||||
if (!helper) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return helper->IsFindUIActive();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface TabGridCoordinator () <BringAndroidTabsCommands,
|
||||
RecentTabsPresentationDelegate,
|
||||
HistoryPresentationDelegate,
|
||||
@ -563,8 +591,11 @@
|
||||
// complete, reset the tab grid mode.
|
||||
self.baseViewController.tabGridMode = TabGridModeNormal;
|
||||
}
|
||||
Browser* browser = self.bvcContainer.incognito ? self.incognitoBrowser
|
||||
: self.regularBrowser;
|
||||
if (!GetFirstResponderInWindowScene(
|
||||
self.baseViewController.view.window.windowScene)) {
|
||||
self.baseViewController.view.window.windowScene) &&
|
||||
!FindNavigatorShouldBePresentedInBrowser(browser)) {
|
||||
// It is possible to already have a first responder (for example the
|
||||
// omnibox). In that case, we don't want to mark BVC as first responder.
|
||||
[self.bvcContainer.currentBVC becomeFirstResponder];
|
||||
|
Reference in New Issue
Block a user