Reputation: 1
I'm trying to solve an issue with focus in react-native search component based upon UISearchController
.
After typing a letter keyboard focus stops working, that means I'm not able to select any other letter anymore when swiping. In the state of "focus-freeze" it is still possible to repeat typing of the last letter though.
This started happening when I switched to Xcode 15 and the latest tvOS SDK, used to work fine in apps built with Xcode 14.x
The focus engine logs do not explain much to me
The result of the focus update was determined from the following preferred focus search:
|
| Starting preferred focus search.
| <UIViewController: 0x10711d180>
| └ <RCTRootView: 0x10711a810>
| │ No more preferred environments. Trying to infer environment from visual layout...
| │ Found environment: <UIKeyboard: 0x105ffcc40>
| └ <UIKeyboard: 0x105ffcc40>
| (info) It's focusable!
|
** TV REMOTE SWIPE - ALL FINE HERE **
Moving focus from <UIKeyboard: 0x105ffcc40> to <UIKeyboard: 0x105ffcc40> in focus system <UIFocusSystem: 0x303568600>.
Ignoring focus update request for disappearing focus environment <UIKBFloatingKeyView: 0x105eeb130>.
** TYPING A LETTER HERE **
- ISSUE: This environment does not contain the currently focused item.
Ignoring focus update request for disappearing focus environment <_UITextLayoutFragmentView: 0x105fff620>.
- ISSUE: This environment does not contain the currently focused item.
Ignoring focus update request for disappearing focus environment <UISearchBarTextFieldLabel: 0x105ff6f70>.
- ISSUE: This environment does not contain the currently focused item.
Ignoring focus update request for disappearing focus environment <UILabel: 0x105ff5090>.
- ISSUE: This environment does not contain the currently focused item.
** SWIPE AGAIN - FOCUS NOT CHANGD AND NO MORE LOGS **
The search controller is embedded into a UIView as follows
//UIView initializer
-(instancetype)init {
if (self = [super initWithFrame: CGRectZero]) {
//results view placeholder controller which will show search results
resultsViewController = [[UIViewController alloc] init];
//seach view controller
search = [[UISearchController alloc]
initWithSearchResultsController: resultsViewController];
search.hidesNavigationBarDuringPresentation = NO;
search.searchResultsUpdater = nil;
//temporary disabled - just to minimize number
//of dependencies when debugging focus issues
//search.searchBar.delegate = self;
search.searchBar.keyboardAppearance = UIKeyboardAppearanceDark;
containerController = [[UISearchContainerViewController alloc]
initWithSearchController:search];
containerController.view.autoresizesSubviews = YES;
[self addSubview: containerController.view];
return self;
}
return nil;
}
//attach UISearchContainerViewController parent UIController
-(void)didMoveToSuperview {
if(self.superview) {
[self reactAddControllerToClosestParent:containerController]; //attach
[self setNeedsLayout];
[self layoutIfNeeded];
}
}
I've confirmed the the TV remote events are still being triggered - i.e. symbolic breakpoint in [UIWindow sendEvent:]
is activated and there are some gesture recognizers attached.
The search view UIView:touchesBegan:withEvent
is not called.
First responder:
(lldb) po [(UIWindow*)$arg1 performSelector:@selector(firstResponder)];
<UISearchBarTextField: 0x1078e1a00; frame = (0 0; 1650 70); text = 'i'; opaque = NO; gestureRecognizers = <NSArray: 0x301f6c4b0>; placeholder = To search, start typing, or select one of your previous searches; borderStyle = RoundedRect; background = <_UITextFieldTVBackgroundProvider: 0x3013be5b0: backgroundView=(null), textfield=<NSKVONotifying_UISearchBarTextField: 0x1078e1a00>>; layer = <CALayer: 0x301690fe0>>
Triggering focus update on UISearchController
via setNeedsFocusUpdate
followed by udateFocusIfNeeded
does not help.
I'd appreciate any hints on how to debug this problem. Is it possible to list gesture recognizers or other objects that are consuming TV remote events ?
Upvotes: 0
Views: 36