Skip to content

Commit 039c394

Browse files
committed
fix: 修复Radio不显示label的bug
1 parent d035cb8 commit 039c394

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

.changeset/tidy-hounds-behave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native': patch
3+
---
4+
5+
fix: 修复Radio不显示label的bug

packages/react-native/src/checkbox/CheckboxItem.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,17 @@ const CheckboxItem: FC<CheckboxItemProps> = ({
4848
const Label = useMemo(() => {
4949
if (typeof label === 'string')
5050
return (
51-
<Text variant="p1" color={disabled ? 'disabled' : 'text'} style={labelStyle}>
52-
{label}
53-
</Text>
51+
<Box flex={1}>
52+
<Text
53+
variant="p1"
54+
color={disabled ? 'disabled' : 'text'}
55+
style={labelStyle}
56+
numberOfLines={1}
57+
ellipsizeMode="tail"
58+
>
59+
{label}
60+
</Text>
61+
</Box>
5462
);
5563
return label;
5664
}, [disabled, label, labelStyle]);

packages/react-native/src/radio/RadioItem.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ const RadioItem: FC<RadioItemProps> = ({
4444
const Label = useMemo(() => {
4545
if (typeof label === 'string') {
4646
return (
47-
<Text variant="p1" color={disabled ? 'disabled' : 'text'} style={labelStyle}>
47+
<Text
48+
variant="p1"
49+
color={disabled ? 'disabled' : 'text'}
50+
style={labelStyle}
51+
numberOfLines={1}
52+
ellipsizeMode="tail"
53+
>
4854
{label}
4955
</Text>
5056
);

0 commit comments

Comments
 (0)