Skip to content

Commit

Permalink
In non-conversation mode, when we search for a keyword, if any item w…
Browse files Browse the repository at this point in the history
…as already shown on screen and if its index on the screen changes, LazyColumn's scrolling behaviour gets broken.

It seems this issue is because of Paging Library-LazyColumn state update mechanism has been broken in the current Compose version. It has been verified that this issue does not appear with Compose 1.7.0-beta01 + Compiler 1.5.14
Until this issue gets resolved by Compose library update, key stability will be provided for search results by adding search mode to the message id to create the item key.

MAILANDR-1842
  • Loading branch information
serdar-ozturk committed May 20, 2024
1 parent 29bd5e2 commit 90d63f5
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ private fun MailboxItemsList(
}
items(
count = items.itemCount,
key = items.itemKey { it.id },
key = items.itemKey { it.id.plus(state.stateKey()) },
contentType = items.itemContentType { MailboxItemUiModel::class }
) { index ->
items[index]?.let { item ->
Expand Down Expand Up @@ -1109,6 +1109,14 @@ private fun MailboxAppendErrorPreview() {
}
}

private fun MailboxListState.stateKey(): String {
return when (this) {
is MailboxListState.Loading -> ""
is MailboxListState.Data.ViewMode -> this.searchState.searchMode.name
is MailboxListState.Data.SelectionMode -> this.searchState.searchMode.name
}
}

object MailboxScreenTestTags {

const val List = "MailboxList"
Expand Down

0 comments on commit 90d63f5

Please sign in to comment.