fix: folder tabs selectable again — long-press via pointerInput/detectTapGestures instead of combinedClickable (Tab's selectable masked the modifier's onClick)

This commit is contained in:
avi 2026-09-07 12:38:57 -05:00
commit 3f84249c82

View file

@ -2,10 +2,9 @@ package com.rada.ui.library
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
@ -64,6 +63,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@ -79,7 +79,7 @@ import com.rada.ui.theme.PremiumSurfaceVariant
import com.rada.ui.theme.PremiumText
import com.rada.ui.theme.PremiumTextSecondary
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LibraryScreen(
onBack: () -> Unit,
@ -210,21 +210,24 @@ fun LibraryScreen(
) {
tabLabels.forEachIndexed { index, label ->
Tab(
modifier = Modifier.combinedClickable(
onClick = {
if (index == 0) {
viewModel.selectPlaylist(null)
} else {
viewModel.selectPlaylist(filteredPlaylists[index - 1].id)
}
},
onLongClick = {
// Long-press a folder tab to delete the group.
if (index > 0) playlistToDelete = filteredPlaylists[index - 1]
},
),
// Long-press detected at the pointer level: putting
// combinedClickable here would be masked by Tab's own
// selectable semantics and break selection entirely.
modifier = Modifier.pointerInput(index) {
detectTapGestures(
onLongPress = {
if (index > 0) playlistToDelete = filteredPlaylists[index - 1]
},
)
},
selected = selectedTabIndex == index,
onClick = { },
onClick = {
if (index == 0) {
viewModel.selectPlaylist(null)
} else {
viewModel.selectPlaylist(filteredPlaylists[index - 1].id)
}
},
text = {
Text(
text = label,