ListItem: Don't apply clickable modifier if onClick is null. (#1146)

If it is applied but disabled (like before this PR) it will hijack all touch input from the view and no other component in it can respond to clicks.
This commit is contained in:
Marco Romano 2023-08-24 17:11:13 +02:00 committed by GitHub
parent b326ca28cc
commit 0abda97d6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -119,7 +119,7 @@ fun ListItem(
androidx.compose.material3.ListItem(
headlineContent = decoratedHeadlineContent,
modifier = Modifier.clickable(enabled = enabled && onClick != null, onClick = onClick ?: {}).then(modifier),
modifier = if (onClick != null) Modifier.clickable(enabled = enabled, onClick = onClick).then(modifier) else modifier,
overlineContent = null,
supportingContent = decoratedSupportingContent,
leadingContent = decoratedLeadingContent,