Is it possible to determine the context in which the Focus Engine looks for the next focused item?

I'm developing a side navigation that pulls out from behind the edge of the screen. The problem is that sometimes the Focus Engine determines the next focused item incorrectly. Instead of selecting the next item in the navigati

on bar, the Focus Engine jumps to the view that is under the navigation bar. This behavior is wrong.


I've tried disabling the container's ability to get focus when the navigation bar is open, but UIFocusGuide stops working in this case.


I also tried to dismiss the focus update if the next focus element is outside the navigation bar. It also didn't help, in which case the transition just doesn't happen.


I use preferredFocusEnvironments to remember the last selected item in the navigation bar.


I have an assumption that my problem can be solved by using focusItems(in rect: CGRect) -> [UIFocusItem]. I tried to implement this method but it didn't have any effect.


In this regard I have three questions:


1. In what direction should I move to solve my problem?

2. How exactly does the Focus Engine look for the next focus element? There is very little information about this.

3. If my assumption about focusItems(in rect: CGRect) -> [UIFocusItem] is incorrect, explain for what purpose does UIFocusItemContainer exist? What problem does it solve?