Fixed
Status Update
Comments
ra...@google.com <ra...@google.com>
my...@globallogic.com <my...@globallogic.com> #2
How did you implement saving/restoring focus on your own?
vi...@google.com <vi...@google.com> #3
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit ee78f0dd46533f9b9cd7e0e588d1c09b19f87785
Author: Ralston Da Silva <ralu@google.com>
Date: Fri Jun 02 13:40:26 2023
FocusRestorer API
Adds an api to restore focus to a previously focused child
Bug: 283243426
Bug: 235681940
Bug: 235691035
Bug: 272302679
Bug: 275157318
Test: ./gradlew compose:ui:ui:cC -P android.testInstrumentationRunnerArguments.package=androidx.compose.ui.focus.FocusRestorerTest
Test: ./gradlew compose:ui:ui:cC -P android.testInstrumentationRunnerArguments.package=androidx.compose.ui.focus.RestoreFocusTest
Relnote: "Added FocusRequester.saveFocusedChild and FocusRequester.restoreFocusedChild"
Change-Id: Ic557eaacc4b5c5fe9f908c5afcc86fc5e84f2bac
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt
A compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusRestorationDemo.kt
M compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/FocusSamples.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusRestorerTest.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/RestoreFocusTest.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusRequester.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusRequesterModifierNode.kt
A compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusRestorer.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusTargetNode.kt
https://android-review.googlesource.com/2612268
Branch: androidx-main
commit ee78f0dd46533f9b9cd7e0e588d1c09b19f87785
Author: Ralston Da Silva <ralu@google.com>
Date: Fri Jun 02 13:40:26 2023
FocusRestorer API
Adds an api to restore focus to a previously focused child
Bug: 283243426
Bug: 235681940
Bug: 235691035
Bug: 272302679
Bug: 275157318
Test: ./gradlew compose:ui:ui:cC -P android.testInstrumentationRunnerArguments.package=androidx.compose.ui.focus.FocusRestorerTest
Test: ./gradlew compose:ui:ui:cC -P android.testInstrumentationRunnerArguments.package=androidx.compose.ui.focus.RestoreFocusTest
Relnote: "Added FocusRequester.saveFocusedChild and FocusRequester.restoreFocusedChild"
Change-Id: Ic557eaacc4b5c5fe9f908c5afcc86fc5e84f2bac
M compose/ui/ui/api/current.txt
M compose/ui/ui/api/restricted_current.txt
M compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/UiDemos.kt
A compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusRestorationDemo.kt
M compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/FocusSamples.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusRestorerTest.kt
A compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/RestoreFocusTest.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusRequester.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusRequesterModifierNode.kt
A compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusRestorer.kt
M compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusTargetNode.kt
ma...@gmail.com <ma...@gmail.com> #5
It seems like the bug could be fixed through the functionality that is offered in the following PR -
https://github.com/androidx/androidx/pull/732
Can't be sure though cause the media is restricted
Can't be sure though cause the media is restricted
rv...@google.com <rv...@google.com> #6
I think this has already been fixed. If you still reproduce this issue using lazy layouts from compose.foundation
(tv lazy layouts have been deprecated and removed), feel free to re-open the ticket.
Description
Steps to reduce:
- Go from one route to another, while having an element focused
- Go back to the initial route
Actual behaviour - the focus is lost
Expected behaviour - the focus should be present
TvLazyRow was used as a demonstration, but the same bug is reproduced while using other components.
NB: The expected behaviour is present in components of Leanback library.
Additional notes on behaviour - If you use a sample project I attach you can observe, that position in the list is retained correctly, but the focus is lost. When you try to press LEFT/RIGHT button, the focus will be moved to a wrong item.
Example: Select element 2, press Enter, go back, press left -> the element 4 is selected.
Example: Select element 2, press Enter, go back, press right -> the element 1 is selected
Example: Select element 2, press Enter, go back, press Enter -> the element 1 is selected and navigation is triggered.
The issue is not device/android version specific.
While it is possible to implement saving/restoring focus on your own, it would be nice to have this this as an out the box feature, since custom solution complexity can significantly increase with complexity of a screen