Skip to content

Fix for missing keyboard accessory view in iOS 16. #1787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: earlgrey2
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions UILib/Provider/GREYUIWindowProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
#import "GREYFatalAsserts.h"
#import "GREYAppleInternals.h"

/** @return The first responder view by searching from @c view. */
static UIView* GetFirstResponderSubview(UIView* view) {
if ([view isFirstResponder]) {
return view;
}

for (UIView* subview in [view subviews]) {
UIView* firstResponder = GetFirstResponderSubview(subview);
if (firstResponder) {
return firstResponder;
}
}

return nil;
}

UIWindow *GREYGetApplicationKeyWindow(UIApplication *application) {
// New API only available on Xcode 13+
#if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000) || \
Expand Down Expand Up @@ -131,6 +147,14 @@ + (NSArray *)windowsFromLevelOfWindow:(UIWindow *)window withStatusBar:(BOOL)inc
[windows addObject:keyWindow];
}

if (@available(iOS 16, *)) {
UIResponder* firstResponder = GetFirstResponderSubview(keyWindow);
UIView* inputView = firstResponder.inputView;
if (inputView) {
[windows addObject:inputView.window];
}
}

if (includeStatusBar) {
UIWindow *statusBarWindow;
// Add the status bar if asked for.
Expand Down