Skip to content

Commit 8208811

Browse files
fix: fixed Chip "shadow" and height issue (#4461)
1 parent 7e938cf commit 8208811

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed

src/components/Chip/Chip.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ const Chip = ({
295295
<Surface
296296
style={[
297297
styles.container,
298-
isV3 &&
299-
(isOutlined ? styles.md3OutlineContainer : styles.md3FlatContainer),
298+
isV3 && styles.md3Container,
300299
!theme.isV3 && {
301300
elevation: elevationStyle,
302301
},
@@ -440,12 +439,9 @@ const styles = StyleSheet.create({
440439
borderStyle: 'solid',
441440
flexDirection: Platform.select({ default: 'column', web: 'row' }),
442441
},
443-
md3OutlineContainer: {
442+
md3Container: {
444443
borderWidth: 1,
445444
},
446-
md3FlatContainer: {
447-
borderWidth: 0,
448-
},
449445
content: {
450446
flexDirection: 'row',
451447
alignItems: 'center',

src/components/Chip/helpers.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ const getBorderColor = ({
2121
const isSelectedColor = selectedColor !== undefined;
2222

2323
if (theme.isV3) {
24+
if (!isOutlined) {
25+
// If the Chip mode is "flat", set border color to transparent
26+
return 'transparent';
27+
}
28+
2429
if (disabled) {
2530
return color(theme.colors.onSurfaceVariant).alpha(0.12).rgb().string();
2631
}

src/components/__tests__/Chip.test.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,7 @@ describe('getChipColor - border color', () => {
669669
isOutlined: false,
670670
})
671671
).toMatchObject({
672-
borderColor: color(getTheme().colors.onSurfaceVariant)
673-
.alpha(0.12)
674-
.rgb()
675-
.string(),
672+
borderColor: 'transparent',
676673
});
677674
});
678675

@@ -684,7 +681,7 @@ describe('getChipColor - border color', () => {
684681
isOutlined: false,
685682
})
686683
).toMatchObject({
687-
borderColor: color('purple').alpha(0.29).rgb().string(),
684+
borderColor: 'transparent',
688685
});
689686
});
690687

@@ -695,7 +692,7 @@ describe('getChipColor - border color', () => {
695692
isOutlined: false,
696693
})
697694
).toMatchObject({
698-
borderColor: getTheme().colors.outline,
695+
borderColor: 'transparent',
699696
});
700697
});
701698

src/components/__tests__/__snapshots__/Chip.test.tsx.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ exports[`renders chip with close button 1`] = `
2323
style={
2424
{
2525
"backgroundColor": "rgba(232, 222, 248, 1)",
26-
"borderColor": "rgba(121, 116, 126, 1)",
26+
"borderColor": "transparent",
2727
"borderRadius": 8,
2828
"borderStyle": "solid",
29-
"borderWidth": 0,
29+
"borderWidth": 1,
3030
"flex": undefined,
3131
"flexDirection": "column",
3232
"shadowColor": "#000",
@@ -332,10 +332,10 @@ exports[`renders chip with custom close button 1`] = `
332332
style={
333333
{
334334
"backgroundColor": "rgba(232, 222, 248, 1)",
335-
"borderColor": "rgba(121, 116, 126, 1)",
335+
"borderColor": "transparent",
336336
"borderRadius": 8,
337337
"borderStyle": "solid",
338-
"borderWidth": 0,
338+
"borderWidth": 1,
339339
"flex": undefined,
340340
"flexDirection": "column",
341341
"shadowColor": "#000",
@@ -641,10 +641,10 @@ exports[`renders chip with icon 1`] = `
641641
style={
642642
{
643643
"backgroundColor": "rgba(232, 222, 248, 1)",
644-
"borderColor": "rgba(121, 116, 126, 1)",
644+
"borderColor": "transparent",
645645
"borderRadius": 8,
646646
"borderStyle": "solid",
647-
"borderWidth": 0,
647+
"borderWidth": 1,
648648
"flex": undefined,
649649
"flexDirection": "column",
650650
"shadowColor": "#000",
@@ -850,10 +850,10 @@ exports[`renders chip with onPress 1`] = `
850850
style={
851851
{
852852
"backgroundColor": "rgba(232, 222, 248, 1)",
853-
"borderColor": "rgba(121, 116, 126, 1)",
853+
"borderColor": "transparent",
854854
"borderRadius": 8,
855855
"borderStyle": "solid",
856-
"borderWidth": 0,
856+
"borderWidth": 1,
857857
"flex": undefined,
858858
"flexDirection": "column",
859859
"shadowColor": "#000",
@@ -1164,10 +1164,10 @@ exports[`renders selected chip 1`] = `
11641164
style={
11651165
{
11661166
"backgroundColor": "rgb(232, 222, 248)",
1167-
"borderColor": "rgba(121, 116, 126, 1)",
1167+
"borderColor": "transparent",
11681168
"borderRadius": 8,
11691169
"borderStyle": "solid",
1170-
"borderWidth": 0,
1170+
"borderWidth": 1,
11711171
"flex": undefined,
11721172
"flexDirection": "column",
11731173
"shadowColor": "#000",

src/components/__tests__/__snapshots__/ListItem.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ exports[`renders list item with custom description 1`] = `
136136
style={
137137
{
138138
"backgroundColor": "rgba(232, 222, 248, 1)",
139-
"borderColor": "rgba(121, 116, 126, 1)",
139+
"borderColor": "transparent",
140140
"borderRadius": 8,
141141
"borderStyle": "solid",
142-
"borderWidth": 0,
142+
"borderWidth": 1,
143143
"flex": undefined,
144144
"flexDirection": "column",
145145
"shadowColor": "#000",

0 commit comments

Comments
 (0)