fix: preserve search screen scroll position across navigation
Replace ephemeral rememberLazyListState() with rememberForeverLazyListState() so the scroll position is persisted when navigating to a search result and back. https://claude.ai/code/session_01PmSFQqSMzP51mtqPLwFEtp
This commit is contained in:
@@ -54,6 +54,8 @@ object ScrollStateKeys {
|
||||
const val DISCOVER_LIVE = "DiscoverLiveFeed"
|
||||
const val DISCOVER_COMMUNITY = "DiscoverCommunitiesFeed"
|
||||
const val DISCOVER_CHATS = "DiscoverChatsFeed"
|
||||
|
||||
const val SEARCH_SCREEN = "SearchFeed"
|
||||
}
|
||||
|
||||
object PagerStateKeys {
|
||||
|
||||
+3
-2
@@ -33,7 +33,8 @@ import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import com.vitorpamplona.amethyst.ui.feeds.ScrollStateKeys
|
||||
import com.vitorpamplona.amethyst.ui.feeds.rememberForeverLazyListState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
@@ -107,7 +108,7 @@ fun SearchScreen(
|
||||
) {
|
||||
WatchLifecycleAndUpdateModel(searchBarViewModel)
|
||||
|
||||
val listState = rememberLazyListState()
|
||||
val listState = rememberForeverLazyListState(ScrollStateKeys.SEARCH_SCREEN)
|
||||
|
||||
LaunchedEffect(searchBarViewModel.focusRequester) {
|
||||
searchBarViewModel.focusRequester.requestFocus()
|
||||
|
||||
Reference in New Issue
Block a user