Closed MarcoFiusco closed 3 years ago
After some debugging sessions, I found out that the problem is caused by the function sortSiblingsByPriority. When I press RIGHT, the array which comes out from this function is sorted wrongly in some cases: the element which is really at the right of the current focused element, is not the 1st. Thanks Marco
Hi,
Please provide debug info about siblings sorted so we can inspect their coordinates. The algorithm is quite straightforward, it sorts based on main axis first, then by the secondary axis. It is also possible that your elements overlap with each other. So far it is quite hard to understand the problem since it works fine in all our apps, as well as the sandbox App.js and App example with boxes with random coordinates.
I found same problem. Create for example FlatList. Then when Element is focused I added transform: scale(1.2). Elements in that scenario are overlapping to each other and this bug occurs. @asgvard
Hi.
Scaling of the element does not change its "real" size or position, it should not impact the logic of the calculation of coordinates. When you use translateX or translateY - it also doesn't impact real coordinates. With the FlatList though - I would assume you have a different issue. FlatList wraps each item into another View (or React.Fragment, I don't remember). And this extra layer of the wrapper might break the calculation of the coordinates for each item. Please try to use "debug: true" mode and see the output of which children elements are suggested to get the next focus and which coordinates do they have.
@asgvard item-18 is missing in calculations:
Also - each element have margin-left - maybe that is the case?
Is this happening after the lazy rendering of the new FlatList items? E.g. after you scrolled far enough past the initial visible chunk of the FlatList? I remember we had similar issues when we tried to use FlatList, and it was due to it creating and removing items on the fly. So it could be that the "old" items having their coordinates to be obsolete at the time when it adds or removed new items during scrolling. First I would try to remove scaling and any other extra styles that could affect this and see how it works then to isolate the issue. Also I would try to go right and then left again and see if it skips this specific item consistently. In the other words, is this behavior occurs only for some specific item, or it's just "random" every time? For now it's hard to say since I can't see every sibling element coordinates.
Ok, I found problem my problem - margin-left was passed to too deep element.
When I have plenty elements on the screen, if I press an arrow button, I.E. right, the focus jumps to the second element to the right of the current focus instead of the first element. Is there any setting or configuration which could help to solve this issue? Thanks Marco