Fix crash after removing last category while it's active in library (#1450)

This commit is contained in:
Cuong-Tran 2024-11-07 21:20:27 +07:00 committed by GitHub
parent 57e6e198b8
commit 9df21583dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,11 +21,12 @@ internal fun LibraryTabs(
getNumberOfMangaForCategory: (Category) -> Int?,
onTabItemClick: (Int) -> Unit,
) {
val currentPageIndex = pagerState.currentPage.coerceAtMost(categories.lastIndex)
Column(
modifier = Modifier.zIndex(1f),
) {
PrimaryScrollableTabRow(
selectedTabIndex = pagerState.currentPage,
selectedTabIndex = currentPageIndex,
edgePadding = 0.dp,
// TODO: use default when width is fixed upstream
// https://issuetracker.google.com/issues/242879624
@ -33,7 +34,7 @@ internal fun LibraryTabs(
) {
categories.forEachIndexed { index, category ->
Tab(
selected = pagerState.currentPage == index,
selected = currentPageIndex == index,
onClick = { onTabItemClick(index) },
text = {
TabText(