Skip to content

Commit 0522664

Browse files
NickGerlemannecolas
authored andcommitted
Add default "overflow: visible" to Text
iOS and Android both historically clip everything outside the bounds of the paragraph/top-level text element. This includes clipping content, when `line-height` would set the bounds to be smaller than the text to be drawn. This is equivalent to setting `overflow: 'hidden'` manually on a paragraph. Changing this default behavior in React Native is scary and breaking, but with Facsimile, it can be controlled with opt-in `overflow: visible`, for web style clipping. Let's set default `overflow: 'visible'`, so that when using web interface, we don't clip the bounds of text (like web doesn't).
1 parent 7157a02 commit 0522664

10 files changed

Lines changed: 254 additions & 14 deletions

File tree

package-lock.json

Lines changed: 46 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-strict-dom/src/native/modules/createStrictDOMTextComponent.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ export function createStrictDOMTextComponent<T, P: StrictProps>(
9898
disableUserSelect ? { userSelect: 'none' } : null
9999
);
100100

101+
// Native components historically clip text. Opt into web-style default of
102+
// visible overflow by default
103+
if (nativeProps.style?.overflow == null) {
104+
nativeProps.style = nativeProps.style ?? {};
105+
nativeProps.style.overflow = 'visible';
106+
}
107+
101108
// Use Animated components if necessary
102109
if (nativeProps.animated === true) {
103110
NativeComponent = ReactNative.Animated.Text;

packages/react-strict-dom/tests/compat/__snapshots__/compat-test.native.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ exports[`<compat.native> "as" equals "span": as=span 1`] = `
4444
style={
4545
{
4646
"color": "blue",
47+
"overflow": "visible",
4748
"userSelect": "none",
4849
}
4950
}
@@ -85,6 +86,7 @@ exports[`<compat.native> nested: nested 1`] = `
8586
{
8687
"boxSizing": "content-box",
8788
"color": "red",
89+
"overflow": "visible",
8890
"position": "static",
8991
}
9092
}

packages/react-strict-dom/tests/contexts/__snapshots__/contexts-ThemeProvider-test.native.js.snap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exports[`<contexts.*> <ThemeProvider> css variable declaration inside a media qu
66
style={
77
{
88
"boxSizing": "content-box",
9+
"overflow": "visible",
910
"position": "static",
1011
"width": 42,
1112
}
@@ -20,6 +21,7 @@ exports[`<contexts.*> <ThemeProvider> defines global custom properties 1`] = `
2021
style={
2122
{
2223
"boxSizing": "content-box",
24+
"overflow": "visible",
2325
"position": "static",
2426
}
2527
}
@@ -33,6 +35,7 @@ exports[`<contexts.*> <ThemeProvider> defines global custom properties 1`] = `
3335
"backgroundColor": "red",
3436
"boxSizing": "content-box",
3537
"color": "red",
38+
"overflow": "visible",
3639
"position": "static",
3740
}
3841
}
@@ -50,6 +53,7 @@ exports[`<contexts.*> <ThemeProvider> kebab case string var to camel case 1`] =
5053
{
5154
"boxSizing": "content-box",
5255
"color": "red",
56+
"overflow": "visible",
5357
"position": "static",
5458
}
5559
}
@@ -60,6 +64,7 @@ exports[`<contexts.*> <ThemeProvider> kebab case string var to camel case 1`] =
6064
{
6165
"boxSizing": "content-box",
6266
"color": "red",
67+
"overflow": "visible",
6368
"position": "static",
6469
}
6570
}
@@ -113,6 +118,7 @@ exports[`<contexts.*> <ThemeProvider> rgb(a) function with args applied through
113118
{
114119
"boxSizing": "content-box",
115120
"color": "rgb(24, 48, 96)",
121+
"overflow": "visible",
116122
"position": "static",
117123
}
118124
}
@@ -123,6 +129,7 @@ exports[`<contexts.*> <ThemeProvider> rgb(a) function with args applied through
123129
{
124130
"boxSizing": "content-box",
125131
"color": "rgba(24, 48, 96, 0.5)",
132+
"overflow": "visible",
126133
"position": "static",
127134
}
128135
}
@@ -137,6 +144,7 @@ exports[`<contexts.*> <ThemeProvider> rgba function with args applied through mu
137144
{
138145
"boxSizing": "content-box",
139146
"color": "rgba(255, 96, 16, 0.42)",
147+
"overflow": "visible",
140148
"position": "static",
141149
}
142150
}
@@ -151,6 +159,7 @@ exports[`<contexts.*> <ThemeProvider> string var 1`] = `
151159
"boxSizing": "content-box",
152160
"color": "red",
153161
"opacity": 0.25,
162+
"overflow": "visible",
154163
"position": "static",
155164
}
156165
}
@@ -164,6 +173,7 @@ exports[`<contexts.*> <ThemeProvider> string var and falls back to a default val
164173
{
165174
"boxSizing": "content-box",
166175
"color": "rgb(255,255,255)",
176+
"overflow": "visible",
167177
"position": "static",
168178
}
169179
}
@@ -177,6 +187,7 @@ exports[`<contexts.*> <ThemeProvider> string var and falls back to default value
177187
{
178188
"boxSizing": "content-box",
179189
"color": "red",
190+
"overflow": "visible",
180191
"position": "static",
181192
}
182193
}
@@ -217,6 +228,7 @@ exports[`<contexts.*> <ThemeProvider> string var with a default value 1`] = `
217228
{
218229
"boxSizing": "content-box",
219230
"color": "red",
231+
"overflow": "visible",
220232
"position": "static",
221233
}
222234
}
@@ -227,6 +239,7 @@ exports[`<contexts.*> <ThemeProvider> string var with a default value 1`] = `
227239
{
228240
"boxSizing": "content-box",
229241
"color": "blue",
242+
"overflow": "visible",
230243
"position": "static",
231244
}
232245
}
@@ -242,6 +255,7 @@ exports[`<contexts.*> <ThemeProvider> string var with a default value containing
242255
{
243256
"boxSizing": "content-box",
244257
"color": "rgb(0,0,0)",
258+
"overflow": "visible",
245259
"position": "static",
246260
}
247261
}
@@ -252,6 +266,7 @@ exports[`<contexts.*> <ThemeProvider> string var with a default value containing
252266
{
253267
"boxSizing": "content-box",
254268
"color": "rgb(1 , 1 , 1)",
269+
"overflow": "visible",
255270
"position": "static",
256271
}
257272
}
@@ -265,6 +280,7 @@ exports[`<contexts.*> <ThemeProvider> textShadow with nested/multiple vars 1`] =
265280
style={
266281
{
267282
"boxSizing": "content-box",
283+
"overflow": "visible",
268284
"position": "static",
269285
"textShadowColor": "red",
270286
"textShadowOffset": {
@@ -283,6 +299,7 @@ exports[`<contexts.*> <ThemeProvider> transform with nested/multiple vars 1`] =
283299
style={
284300
{
285301
"boxSizing": "content-box",
302+
"overflow": "visible",
286303
"position": "static",
287304
"transform": [
288305
{

packages/react-strict-dom/tests/contexts/__snapshots__/contexts-ViewportProvider-test.native.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ exports[`<contexts.*> <ViewportProvider> all CSS lengths are scaled according to
3030
"boxSizing": "content-box",
3131
"fontSize": 24,
3232
"lineHeight": 24,
33+
"overflow": "visible",
3334
"position": "static",
3435
}
3536
}
@@ -42,6 +43,7 @@ exports[`<contexts.*> <ViewportProvider> all CSS lengths are scaled according to
4243
{
4344
"boxSizing": "content-box",
4445
"fontSize": 18,
46+
"overflow": "visible",
4547
"position": "static",
4648
}
4749
}

packages/react-strict-dom/tests/css/__snapshots__/css-create-queries-test.native.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exports[`css.create(): @media query does not match (prefers-color-scheme: dark)
66
"borderColor": "green",
77
"boxSizing": "content-box",
88
"color": "black",
9+
"overflow": "visible",
910
"position": "static",
1011
}
1112
`;
@@ -16,6 +17,7 @@ exports[`css.create(): @media query does not match (prefers-color-scheme: light)
1617
"borderColor": "darkgreen",
1718
"boxSizing": "content-box",
1819
"color": "white",
20+
"overflow": "visible",
1921
"position": "static",
2022
}
2123
`;
@@ -26,6 +28,7 @@ exports[`css.create(): @media query matches (prefers-color-scheme: dark) 1`] = `
2628
"borderColor": "darkgreen",
2729
"boxSizing": "content-box",
2830
"color": "white",
31+
"overflow": "visible",
2932
"position": "static",
3033
}
3134
`;
@@ -36,6 +39,7 @@ exports[`css.create(): @media query matches (prefers-color-scheme: light) 1`] =
3639
"borderColor": "green",
3740
"boxSizing": "content-box",
3841
"color": "black",
42+
"overflow": "visible",
3943
"position": "static",
4044
}
4145
`;

0 commit comments

Comments
 (0)