textAlign Right is making the text go outside of the canvas
See original GitHub issueBug description:
Trying to generate a table with rows and columns in Hebrew
For that, I’m using textAlign: 'right'
method to align all my text to the right side, in addition to flexDirection: 'row-reverse'
const styles = StyleSheet.create({
row: {
flexDirection: 'row',
},
rowA: {
textAlign: 'right',
backgroundColor: 'red',
flexGrow: 4,
},
rowB: {
textAlign: 'right',
backgroundColor: 'red',
flexGrow: 2
},
rowC: {
textAlign: 'right',
backgroundColor: 'red',
flexGrow: 2
}
});
<Document>
<Page size="A4" style={styles.page}>
<View style={styles.row}>
<Text style={[styles.rowA, styles.text]}>A</Text>
<Text style={[styles.rowB, styles.text]}>B</Text>
<Text style={[styles.rowC, styles.text]}>C</Text>
</View>
</Page>
</Document>
Expected behavior Text should not want to make me jump from a cliff and just align to the right side as it usually does
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why does text-align have an effect on canvas? - Stack Overflow
In short: The above answers only work if your canvas is the same width as the container. If I comment out text-align my...
Read more >HTML canvas textAlign Property - W3Schools
The textAlign property sets or returns the current alignment for text content, according to the anchor point. Normally, the text will START in...
Read more >CanvasRenderingContext2D.textAlign - Web APIs | MDN
The CanvasRenderingContext2D.textAlign property of the Canvas 2D API specifies the current text alignment used when drawing text.
Read more >Alignment, font styles, and horizontal rules in HTML documents
15 Alignment, font styles, and horizontal rules · This example centers a heading on the canvas. · Similarly, to right align a paragraph...
Read more >Solved: Wrap Text around a Picture? - Canvas Community
Then, click on the button to left align to the page. Does that work for you? Or, have you tried using the Format...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in latest build
I had the same problem, with a container that has
justifyContent: 'space-between'
, and the rightmost item had Text withtextAlign: 'right'
. I had to removespace-between
, and instead addedflex:1
to each item inside the container. It seems that the root of this issue is some defaults that are not set on View components that are children of adisplay: 'flex'
View. The difference betweenflex: 1
andflexGrow: 1
is that the flex shorthand also sets flex-shrink: 1 and flex-basis: 0. After some testing it seems thatflexBasis: 0
is required when usingflexGrow
to wrap some aligned text.Edit: This is also happening on the v2 : @react-pdf/renderer@2.0.0-beta.15