Skip to content

Commit e10397f

Browse files
authored
Add inline view with lineHeight example to TextInlineView (#59418)
Summary: Add a new RNTester example in TextInlineView that reproduces the issue where setting a line height for Text breaks expected CSS behavior with inline views and images. Changelog: [Internal] Reviewed By: Abbondanzo Differential Revision: D126542681 Pull Request resolved: #59418
1 parent e4b5b24 commit e10397f

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

‎packages/rn-tester/js/components/TextInlineView.js‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,70 @@ function ChangeInnerViewSize(): React.Node {
199199
);
200200
}
201201

202+
component ChangeLineHeight() {
203+
return (
204+
<View>
205+
<InlineImageLineHeightCase
206+
label="no lineHeight, view: 35 (reference)"
207+
size={35}
208+
/>
209+
<InlineImageLineHeightCase
210+
label="lineHeight: 15, view: 35"
211+
lineHeight={15}
212+
size={35}
213+
/>
214+
<InlineImageLineHeightCase
215+
label="lineHeight: 40, smaller view: 20"
216+
lineHeight={40}
217+
size={20}
218+
/>
219+
</View>
220+
);
221+
}
222+
223+
component InlineImageLineHeightCase(
224+
label: string,
225+
size: number,
226+
lineHeight?: number,
227+
) {
228+
return (
229+
<View style={{marginBottom: 12}}>
230+
<RNTesterText variant="label">{label}</RNTesterText>
231+
<View
232+
style={{
233+
borderWidth: 1,
234+
borderColor: 'grey',
235+
marginTop: 4,
236+
padding: 4,
237+
backgroundColor: 'lightgrey',
238+
}}>
239+
<RNTesterText style={{lineHeight}}>
240+
This text{' '}
241+
<View
242+
style={{width: size, height: size, backgroundColor: 'steelblue'}}
243+
/>{' '}
244+
contains multiple inline blue views. The inline views should be
245+
contained within the container and should not overflow on any other
246+
lines.{' '}
247+
<View
248+
style={{width: size, height: size, backgroundColor: 'steelblue'}}
249+
/>{' '}
250+
The line spacing between every line should be consistent as well.{' '}
251+
<View
252+
style={{width: size, height: size, backgroundColor: 'steelblue'}}
253+
/>
254+
</RNTesterText>
255+
</View>
256+
</View>
257+
);
258+
}
259+
202260
module.exports = {
203261
Basic,
204262
NestedTexts,
205263
ClippedByText,
206264
ChangeImageSize,
207265
ChangeViewSize,
208266
ChangeInnerViewSize,
267+
ChangeLineHeight,
209268
};

‎packages/rn-tester/js/examples/Text/TextExample.android.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,13 @@ const examples = [
17991799
return <TextInlineView.Basic />;
18001800
},
18011801
},
1802+
{
1803+
title: 'Inline views with line height',
1804+
name: 'inlineViewsLineHeight',
1805+
render(): React.Node {
1806+
return <TextInlineView.ChangeLineHeight />;
1807+
},
1808+
},
18021809
{
18031810
title: 'Inline views with multiple nested texts',
18041811
name: 'inlineViewsMultiple',

‎packages/rn-tester/js/examples/Text/TextExample.ios.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,13 @@ const examples = [
13101310
title: 'Inline views',
13111311
render: (): React.Node => <TextInlineView.Basic />,
13121312
},
1313+
{
1314+
title: 'Inline views with line height',
1315+
name: 'inlineViewsLineHeight',
1316+
render(): React.Node {
1317+
return <TextInlineView.ChangeLineHeight />;
1318+
},
1319+
},
13131320
{
13141321
title: 'Inline image/view clipped by <Text>',
13151322
render: (): React.Node => <TextInlineView.ClippedByText />,

0 commit comments

Comments
 (0)