Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ data class SnackBarItemModel(
val id: String = java.util.UUID.randomUUID().toString(),
val style: SnackbarStyle = SnackbarStyle.Neutral,
val leadingIcon: FluentIcon? = null,
val trailingIcon: FluentIcon? = null,
var trailingIcon: FluentIcon? = null,
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing trailingIcon from val to var in a data class marked with @Stable is problematic. The @Stable annotation tells Compose that the object is immutable, but introducing a mutable property violates this contract. This can lead to recomposition issues where changes to the trailingIcon won't trigger proper UI updates. Consider creating a new instance of the model with the updated trailingIcon using the data class copy() method instead of mutating the property.

Suggested change
var trailingIcon: FluentIcon? = null,
val trailingIcon: FluentIcon? = null,

Copilot uses AI. Check for mistakes.
val subTitle: String? = null,
val actionText: String? = null,
val snackBarToken: StackableSnackBarTokens = DEFAULT_SNACKBAR_TOKENS,
Expand Down Expand Up @@ -606,6 +606,7 @@ private fun SnackBarStackItem(
}
}


val textPaddingValues =
if (model.actionText == null && model.trailingIcon != null) PaddingValues(
start = 16.dp,
Expand Down Expand Up @@ -786,24 +787,24 @@ private fun SnackBarStackItem(
)
}

if (model.trailingIcon != null && model.trailingIcon.isIconAvailable()) {
if (model.trailingIcon != null && model.trailingIcon!!.isIconAvailable()) {
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The non-null assertion operator !! is used here despite the null check immediately before. This is redundant and risky. Consider using smart casting by extracting the trailingIcon to a local variable after the null check, or use a safe call operator with let block to handle the non-null case.

Copilot uses AI. Check for mistakes.
Box(
modifier = Modifier
.testTag(SnackBarTestTags.SNACK_BAR_ICON)
.then(
if (model.trailingIcon.onClick != null) {
if (model.trailingIcon!!.onClick != null) {
Modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(),
enabled = true,
role = Role.Image,
onClick = model.trailingIcon.onClick!!
onClick = model.trailingIcon!!.onClick!!
)
} else Modifier
)
) {
Icon(
model.trailingIcon,
model.trailingIcon!!,
Comment on lines +795 to +807
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple non-null assertion operators !! are used here and in lines 801 and 807. Since trailingIcon was already verified as non-null in line 790, Kotlin smart casting should work with a local variable. Refactor this code block to use a local variable or a let block to avoid the repeated use of !!.

Copilot uses AI. Check for mistakes.
modifier = Modifier
.padding(top = 12.dp, bottom = 12.dp, end = 16.dp)
.size(token.leftIconSize(snackBarInfo)),
Expand Down