Skip to content

Commit 47671ca

Browse files
committed
[fix] Text inheritance of textAlign
Set textAlign on the default Text element. Prevents inheritance of textAlign set on a parent View. Fix #2498
1 parent 29fcd9a commit 47671ca

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

packages/react-native-web/src/exports/AppRegistry/__tests__/index-test.node.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('AppRegistry', () => {
4545
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);}
4646
input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-webkit-search-results-button,input::-webkit-search-results-decoration{display:none;}
4747
[stylesheet-group=\\"1\\"]{}
48-
.css-text-13q1o4w{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:rgba(0,0,0,1.00);display:inline;font:14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;list-style:none;margin:0px;padding:0px;position:relative;text-align:inherit;text-decoration:none;white-space:pre-wrap;word-wrap:break-word;}
48+
.css-text-146c3p1{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:rgba(0,0,0,1.00);display:inline;font:14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;list-style:none;margin:0px;padding:0px;position:relative;text-align:start;text-decoration:none;white-space:pre-wrap;word-wrap:break-word;}
4949
.css-textHasAncestor-1jxf684{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:inherit;display:inline;font:inherit;list-style:none;margin:0px;padding:0px;position:relative;text-align:inherit;text-decoration:none;white-space:inherit;word-wrap:break-word;}
5050
.css-view-175oi2r{align-items:stretch;background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;display:flex;flex-basis:auto;flex-direction:column;flex-shrink:0;list-style:none;margin:0px;min-height:0px;min-width:0px;padding:0px;position:relative;text-decoration:none;z-index:0;}
5151
[stylesheet-group=\\"2\\"]{}
@@ -102,7 +102,7 @@ describe('AppRegistry', () => {
102102
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);}
103103
input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-webkit-search-results-button,input::-webkit-search-results-decoration{display:none;}
104104
[stylesheet-group=\\"1\\"]{}
105-
.css-text-13q1o4w{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:rgba(0,0,0,1.00);display:inline;font:14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;list-style:none;margin:0px;padding:0px;position:relative;text-align:inherit;text-decoration:none;white-space:pre-wrap;word-wrap:break-word;}
105+
.css-text-146c3p1{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:rgba(0,0,0,1.00);display:inline;font:14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;list-style:none;margin:0px;padding:0px;position:relative;text-align:start;text-decoration:none;white-space:pre-wrap;word-wrap:break-word;}
106106
.css-textHasAncestor-1jxf684{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:inherit;display:inline;font:inherit;list-style:none;margin:0px;padding:0px;position:relative;text-align:inherit;text-decoration:none;white-space:inherit;word-wrap:break-word;}
107107
.css-view-175oi2r{align-items:stretch;background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;display:flex;flex-basis:auto;flex-direction:column;flex-shrink:0;list-style:none;margin:0px;min-height:0px;min-width:0px;padding:0px;position:relative;text-decoration:none;z-index:0;}
108108
[stylesheet-group=\\"2\\"]{}
@@ -150,7 +150,7 @@ describe('AppRegistry', () => {
150150
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);}
151151
input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-webkit-search-results-button,input::-webkit-search-results-decoration{display:none;}
152152
[stylesheet-group=\\"1\\"]{}
153-
.css-text-13q1o4w{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:rgba(0,0,0,1.00);display:inline;font:14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;list-style:none;margin:0px;padding:0px;position:relative;text-align:inherit;text-decoration:none;white-space:pre-wrap;word-wrap:break-word;}
153+
.css-text-146c3p1{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:rgba(0,0,0,1.00);display:inline;font:14px -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,sans-serif;list-style:none;margin:0px;padding:0px;position:relative;text-align:start;text-decoration:none;white-space:pre-wrap;word-wrap:break-word;}
154154
.css-textHasAncestor-1jxf684{background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;color:inherit;display:inline;font:inherit;list-style:none;margin:0px;padding:0px;position:relative;text-align:inherit;text-decoration:none;white-space:inherit;word-wrap:break-word;}
155155
.css-view-175oi2r{align-items:stretch;background-color:rgba(0,0,0,0.00);border:0 solid black;box-sizing:border-box;display:flex;flex-basis:auto;flex-direction:column;flex-shrink:0;list-style:none;margin:0px;min-height:0px;min-width:0px;padding:0px;position:relative;text-decoration:none;z-index:0;}
156156
[stylesheet-group=\\"2\\"]{}

packages/react-native-web/src/exports/Text/__tests__/__snapshots__/index-test.js.snap

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
exports[`components/Text default 1`] = `
44
<div
5-
class="css-text-13q1o4w"
5+
class="css-text-146c3p1"
66
dir="auto"
77
/>
88
`;
99

1010
exports[`components/Text nested 1`] = `
1111
<div
12-
class="css-text-13q1o4w"
12+
class="css-text-146c3p1"
1313
dir="auto"
1414
>
1515
<span
@@ -22,44 +22,44 @@ exports[`components/Text nested 1`] = `
2222
exports[`components/Text prop "aria-label" value is set 1`] = `
2323
<div
2424
aria-label="accessibility label"
25-
class="css-text-13q1o4w"
25+
class="css-text-146c3p1"
2626
dir="auto"
2727
/>
2828
`;
2929

3030
exports[`components/Text prop "aria-labelledby" value is set 1`] = `
3131
<div
3232
aria-labelledby="123"
33-
class="css-text-13q1o4w"
33+
class="css-text-146c3p1"
3434
dir="auto"
3535
/>
3636
`;
3737

3838
exports[`components/Text prop "aria-live" value is set 1`] = `
3939
<div
4040
aria-live="polite"
41-
class="css-text-13q1o4w"
41+
class="css-text-146c3p1"
4242
dir="auto"
4343
/>
4444
`;
4545

4646
exports[`components/Text prop "dir" value is "ltr" 1`] = `
4747
<div
48-
class="css-text-13q1o4w"
48+
class="css-text-146c3p1"
4949
dir="ltr"
5050
/>
5151
`;
5252

5353
exports[`components/Text prop "dir" value is "rtl" 1`] = `
5454
<div
55-
class="css-text-13q1o4w"
55+
class="css-text-146c3p1"
5656
dir="rtl"
5757
/>
5858
`;
5959

6060
exports[`components/Text prop "href" href with accessibilityRole 1`] = `
6161
<a
62-
class="css-text-13q1o4w"
62+
class="css-text-146c3p1"
6363
dir="auto"
6464
href="https://example.com"
6565
role="presentation"
@@ -68,30 +68,30 @@ exports[`components/Text prop "href" href with accessibilityRole 1`] = `
6868

6969
exports[`components/Text prop "href" value is set 1`] = `
7070
<a
71-
class="css-text-13q1o4w"
71+
class="css-text-146c3p1"
7272
dir="auto"
7373
href="https://example.com"
7474
/>
7575
`;
7676

7777
exports[`components/Text prop "hrefAttrs" null values are excluded 1`] = `
7878
<a
79-
class="css-text-13q1o4w"
79+
class="css-text-146c3p1"
8080
dir="auto"
8181
href="https://example.com"
8282
/>
8383
`;
8484

8585
exports[`components/Text prop "hrefAttrs" requires "href" 1`] = `
8686
<div
87-
class="css-text-13q1o4w"
87+
class="css-text-146c3p1"
8888
dir="auto"
8989
/>
9090
`;
9191

9292
exports[`components/Text prop "hrefAttrs" target variant is set 1`] = `
9393
<a
94-
class="css-text-13q1o4w"
94+
class="css-text-146c3p1"
9595
dir="auto"
9696
href="https://example.com"
9797
target="_blank"
@@ -100,7 +100,7 @@ exports[`components/Text prop "hrefAttrs" target variant is set 1`] = `
100100

101101
exports[`components/Text prop "hrefAttrs" value is set 1`] = `
102102
<a
103-
class="css-text-13q1o4w"
103+
class="css-text-146c3p1"
104104
dir="auto"
105105
download="filename.jpg"
106106
href="https://example.com"
@@ -111,68 +111,68 @@ exports[`components/Text prop "hrefAttrs" value is set 1`] = `
111111

112112
exports[`components/Text prop "lang" ar 1`] = `
113113
<div
114-
class="css-text-13q1o4w"
114+
class="css-text-146c3p1"
115115
dir="rtl"
116116
lang="ar"
117117
/>
118118
`;
119119

120120
exports[`components/Text prop "lang" fr 1`] = `
121121
<div
122-
class="css-text-13q1o4w"
122+
class="css-text-146c3p1"
123123
dir="ltr"
124124
lang="fr"
125125
/>
126126
`;
127127

128128
exports[`components/Text prop "lang" undefined 1`] = `
129129
<div
130-
class="css-text-13q1o4w"
130+
class="css-text-146c3p1"
131131
dir="auto"
132132
/>
133133
`;
134134

135135
exports[`components/Text prop "lang" with dir 1`] = `
136136
<div
137-
class="css-text-13q1o4w"
137+
class="css-text-146c3p1"
138138
dir="ltr"
139139
lang="ar"
140140
/>
141141
`;
142142

143143
exports[`components/Text prop "nativeID" value is set 1`] = `
144144
<div
145-
class="css-text-13q1o4w"
145+
class="css-text-146c3p1"
146146
dir="auto"
147147
id="nativeID"
148148
/>
149149
`;
150150

151151
exports[`components/Text prop "numberOfLines" value is set 1`] = `
152152
<div
153-
class="css-text-13q1o4w r-WebkitBoxOrient-8akbws r-display-krxsd3 r-maxWidth-dnmrzs r-overflow-1udh08x r-textOverflow-1udbk01"
153+
class="css-text-146c3p1 r-WebkitBoxOrient-8akbws r-display-krxsd3 r-maxWidth-dnmrzs r-overflow-1udh08x r-textOverflow-1udbk01"
154154
dir="auto"
155155
/>
156156
`;
157157

158158
exports[`components/Text prop "numberOfLines" value is set to one 1`] = `
159159
<div
160-
class="css-text-13q1o4w r-maxWidth-dnmrzs r-overflow-1udh08x r-textOverflow-1udbk01 r-whiteSpace-3s2u2q r-wordWrap-1iln25a"
160+
class="css-text-146c3p1 r-maxWidth-dnmrzs r-overflow-1udh08x r-textOverflow-1udbk01 r-whiteSpace-3s2u2q r-wordWrap-1iln25a"
161161
dir="auto"
162162
/>
163163
`;
164164

165165
exports[`components/Text prop "role" value alters HTML element 1`] = `
166166
<article
167-
class="css-text-13q1o4w"
167+
class="css-text-146c3p1"
168168
dir="auto"
169169
role="article"
170170
/>
171171
`;
172172

173173
exports[`components/Text prop "role" value is "button" 1`] = `
174174
<button
175-
class="css-text-13q1o4w"
175+
class="css-text-146c3p1"
176176
dir="auto"
177177
role="button"
178178
type="button"
@@ -181,37 +181,37 @@ exports[`components/Text prop "role" value is "button" 1`] = `
181181

182182
exports[`components/Text prop "role" value is set 1`] = `
183183
<div
184-
class="css-text-13q1o4w"
184+
class="css-text-146c3p1"
185185
dir="auto"
186186
role="presentation"
187187
/>
188188
`;
189189

190190
exports[`components/Text prop "selectable" value of false 1`] = `
191191
<div
192-
class="css-text-13q1o4w r-userSelect-lrvibr"
192+
class="css-text-146c3p1 r-userSelect-lrvibr"
193193
dir="auto"
194194
/>
195195
`;
196196

197197
exports[`components/Text prop "selectable" value of true 1`] = `
198198
<div
199-
class="css-text-13q1o4w r-userSelect-1xnzce8"
199+
class="css-text-146c3p1 r-userSelect-1xnzce8"
200200
dir="auto"
201201
/>
202202
`;
203203

204204
exports[`components/Text prop "style" value is set 1`] = `
205205
<div
206-
class="css-text-13q1o4w"
206+
class="css-text-146c3p1"
207207
dir="auto"
208208
style="border-top-width: 5px; border-right-width: 5px; border-bottom-width: 5px; border-left-width: 5px;"
209209
/>
210210
`;
211211

212212
exports[`components/Text prop "testID" value is set 1`] = `
213213
<div
214-
class="css-text-13q1o4w"
214+
class="css-text-146c3p1"
215215
data-testid="123"
216216
dir="auto"
217217
/>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const textStyle = {
193193
margin: 0,
194194
padding: 0,
195195
position: 'relative',
196-
textAlign: 'inherit',
196+
textAlign: 'start',
197197
textDecoration: 'none',
198198
whiteSpace: 'pre-wrap',
199199
wordWrap: 'break-word'
@@ -205,6 +205,7 @@ const styles = StyleSheet.create({
205205
...textStyle,
206206
color: 'inherit',
207207
font: 'inherit',
208+
textAlign: 'inherit',
208209
whiteSpace: 'inherit'
209210
},
210211
textOneLine: {

0 commit comments

Comments
 (0)