Closed Andre-Pham closed 2 years ago
I've had a discussion with @Chokss54 about this as the same issue occurs in JumpText
on certain fragment transitions. We couldn't find any other cases of this behaviour occurring but we were able to use sendAccessibilityEvent
to force it to work. However, this solution doesn't work in this module.
To reproduce, you need two fragments with the same layout structure, in this case being
ScrollView
LinearLayout
View
$\times n$The second fragment can have the same or more number of View
s at the bottom. This bug doesn't happen if the second view has fewer View
s than the first.
When you replace the first fragment with the second, TalkBack's focus will remain in the exact same place in the layout hierarchy as it was in the first fragment.
Fragment 1 | Fragment 2 | |
---|---|---|
View | View | |
View | $\nearrow$ | View |
View | View | |
View |
When replacing Fragment 1 with Fragment 2, TalkBack should focus on the first View
.
Fragment 1 | Fragment 2 | |
---|---|---|
View | View | |
View | View | |
View | $\rightarrow$ | View |
View |
When replacing Fragment 1 with Fragment 2, TalkBack erroneously focuses on the View
that corresponds with the View
of the previous layout.
The same thing happens in the opposite direction if you use the back stack. In this scenario, if you move to the 3rd View
and go back, you end up on the 3rd View
in the previous fragment. Strangely, when modifying JumpText
as a test, the 2nd View
mapped to the 1st View
of the previous fragment.
This issue exhibits some exceptionally unusual behaviour in Android and I do not know how to fix it in this case. The solution used elsewhere to resolve this kind of problem is a hack, as focus is still going to the wrong place initially. There's a chance that this issue is caused by a bug in Android or TalkBack.
A quick fix would be to add more View
s to the previous fragment so that the criteria for the bug are no longer met.
A quick fix (1 second time delay for sendAccessibilityEvent
) was implemented in 302d38d9e3f25fc92f041151fad43b81126f6048.
When returning from the external app the first time the last item (the button) was focused, instead of the first text element.