Skip to content

Commit

Permalink
Fix Chip background not clipped when pressed (#1903)
Browse files Browse the repository at this point in the history
* Clip to ChipShape before applying selectable

* Updated snapshots

* Dismissible chip - clip to shape before clickable

* Updated snapshots

---------

Co-authored-by: Andra-Georgescu <Andra.Georgescu@skyscanner.net>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
3 people authored Mar 18, 2024
1 parent a7c155f commit be9c7d8
Showing 55 changed files with 14 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ package net.skyscanner.backpack.compose.chip.internal

import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
@@ -33,6 +32,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@@ -80,12 +80,13 @@ internal fun BpkChipImpl(
type = type,
interactionSource = interactionSource,
modifier = modifier.applyIf(onSelectedChange != null) {
selectable(
selected = selected,
enabled = enabled,
interactionSource = interactionSource,
indication = LocalIndication.current,
) { onSelectedChange!!.invoke(!selected) }
clip(ChipShape)
.selectable(
selected = selected,
enabled = enabled,
interactionSource = interactionSource,
indication = rememberRipple(),
) { onSelectedChange!!.invoke(!selected) }
},
)
}
@@ -108,10 +109,11 @@ internal fun BpkDismissibleChipImpl(
type = BpkChipType.Dismiss,
interactionSource = interactionSource,
modifier = modifier.applyIf(onClick != null) {
clickable(
interactionSource = interactionSource,
indication = LocalIndication.current,
) { onClick!!.invoke() }
clip(ChipShape)
.clickable(
interactionSource = interactionSource,
indication = rememberRipple(),
) { onClick!!.invoke() }
},
)
}
@@ -199,6 +201,7 @@ internal fun BpkChipImpl(
default = style.dismissibleTrailingIconColor,
pressed = style.dismissibleTrailingIconPressedColor,
)

selected -> style.selectedContentColor
else -> interactionSource.animateAsColor(
default = style.contentColor,

0 comments on commit be9c7d8

Please sign in to comment.