Skip to content

Commit bcdb6fa

Browse files
committed
fix(text): allow vertical overflow for text with numberOfLines={1}
1 parent a9de220 commit bcdb6fa

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

  • packages
    • react-native-web-examples/pages/text
    • react-native-web/src/exports/Text

packages/react-native-web-examples/pages/text/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ function LineExample({ description, children }) {
314314

315315
<View
316316
style={{
317-
borderWidth: 2,
317+
borderWidth: 1,
318318
borderColor: 'black',
319319
width: 200
320320
}}
@@ -462,6 +462,22 @@ export default function TextPage() {
462462
</Text>
463463
</LineExample>
464464

465+
<LineExample description="With reduced line height, vertical content is not clipped (1 line)">
466+
<Text numberOfLines={1} style={{ lineHeight: 8 }}>
467+
{
468+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\nExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
469+
}
470+
</Text>
471+
</LineExample>
472+
473+
<LineExample description="With reduced line height, vertical content is not clipped (2 lines, not working)">
474+
<Text numberOfLines={2} style={{ lineHeight: 8 }}>
475+
{
476+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\nDuis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\nExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
477+
}
478+
</Text>
479+
</LineExample>
480+
465481
<LineExample description="With space characters within adjacent truncated lines">
466482
<View style={{ display: 'flex', flexDirection: 'row' }}>
467483
<Text numberOfLines={1}>

packages/react-native-web/src/exports/Text/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const styles = StyleSheet.create({
214214
},
215215
textOneLine: {
216216
maxWidth: '100%',
217-
overflow: 'hidden',
217+
overflowInline: 'clip',
218218
textOverflow: 'ellipsis',
219219
whiteSpace: 'nowrap',
220220
wordWrap: 'normal'

0 commit comments

Comments
 (0)