android / tv-samples

Multiple samples showing best practices in app development on Android TV.
Apache License 2.0
1.06k stars 339 forks source link

JetStream crashes on home screem : Focus restoration on navigation popBackStack and focus restoration using state Modifiers #148

Closed ChetanPatelPlayBoxTV closed 6 months ago

ChetanPatelPlayBoxTV commented 10 months ago

In the JetStream tv app sample, it has a createInitialFocusRestorerModifiers() function which acts as the focus restorers of a TvLazyRow/Column for its children.

When I tried to scroll to the end item of the list - making the first item hidden from the current view - and tried to go to my second screen and immediately pop back from it, the app constantly throws:

` java.lang.IllegalStateException: FocusRequester is not initialized. Here are some possible fixes:

  1. Remember the FocusRequester: val focusRequester = remember { FocusRequester() }
  2. Did you forget to add a Modifier.focusRequester() ?
  3. Are you attempting to request focus during composition? Focus requests should be made in response to some event. Eg Modifier.clickable { focusRequester.requestFocus() } at androidx.compose.ui.focus.FocusRequester.focus$ui_release(FocusRequester.kt:259) at androidx.compose.ui.focus.FocusTransactionsKt.performCustomEnter-Mxy_nc0(FocusTransactions.kt:293) at androidx.compose.ui.focus.FocusTransactionsKt.performCustomRequestFocus-Mxy_nc0(FocusTransactions.kt:271)`
alexzaitsev commented 9 months ago

Have you found a solution @ChetanPatelPlayBoxTV ? Seems to be an issue in FocusRestorer modifier.

ChetanPatelPlayBoxTV commented 9 months ago

Have you found a solution @ChetanPatelPlayBoxTV ? Seems to be an issue in FocusRestorer modifier.

@alexzaitsev Sorry still I'm facing same issue, it's not resolved.

ChetanPatelPlayBoxTV commented 7 months ago

any update @androidTeam @alexzaitsev @dakkad @tjohns

How can I solved this issue ?

chikoski commented 6 months ago

This issue can be fixed by this, which is applied by #168

ChetanPatelPlayBoxTV commented 6 months ago

thanks @chikoski for update me and give me quick solution.

chemickypes commented 4 months ago

Where do I have to see the solution? Which files?