react-pdf
react-pdf copied to clipboard
Crash when overflowing text inside a view with a height
Describe the bug
When rendering text that overflows its container (even if it's overflow hidden) I get the following error:
worker.ts:38 TypeError: Cannot read properties of undefined (reading 'y')
at textkit.es.js:787:1
at Array.map (<anonymous>)
at layoutLines (textkit.es.js:778:1)
at textkit.es.js:825:1
at textkit.es.js:877:1
at compose.js:32:1
at textkit.es.js:1748:19
at layoutText (index.es.js:2085:1)
at index.es.js:2926:1
This did not occur in version 2.1.1, but did in 2.3.0
To Reproduce The following code will reproduce the error in the repl
const styles = {
container: {
height: 30,
},
content: {
overflow: 'hidden',
textOverflow: 'ellipsis',
maxLines: 1,
},
};
function TextOverflowError() {
return (
<Document>
<Page>
<View style={styles.container}>
<Text style={styles.content}>
En un lugar de la Mancha, de cuyo nombre no quiero
acordarme, no ha mucho tiempo que vivĂa un hidalgo de
los de lanza en astillero, adarga antigua, rocĂn flaco y
galgo corredor. Una olla de algo más vaca que carnero,
salpicón las más noches, duelos y quebrantos los
sábados, lentejas los viernes, algún palomino de
añadidura los domingos, consumĂan las tres partes de su
hacienda. El resto della concluĂan sayo de velarte,
calzas de velludo para las fiestas con sus pantuflos de
lo mismo, los dĂas de entre semana se honraba con su
vellori de lo más fino. TenĂa en su casa una ama que
pasaba de los cuarenta, y una sobrina que no llegaba a
los veinte, y un mozo de campo y plaza, que asĂ
ensillaba el rocĂn como tomaba la podadera. Frisaba la
edad de nuestro hidalgo con los cincuenta años, era de
complexiĂłn recia, seco de carnes, enjuto de rostro; gran
madrugador y amigo de la caza. Quieren decir que tenĂa
el sobrenombre de Quijada o Quesada (que en esto hay
alguna diferencia en los autores que deste caso
escriben), aunque por conjeturas verosĂmiles se deja
entender que se llama Quijana; pero esto importa poco a
nuestro cuento; basta que en la narración dél no se
salga un punto de la verdad
</Text>
</View>
</Page>
</Document>
);
}
ReactPDF.render(<TextOverflowError />);
Expected behavior A crash to not occur
I'm having the same issue since the update to the latest version
We experience the same bug when upgrading from @react-pdf/[email protected] to @react-pdf/[email protected].
Additionally, when a Text is inside a View with a fixed height, whilst the text itself needs more height, the rendering crashes too.
I already fixed this in #1917. We just have to wait for a release of react-pdf which includes this.
I already fixed this in #1917. We just have to wait for a release of react-pdf which includes this.
When will this be released? I think it's critical.
Do we have any idea when a new version will be released?
any chance for a release here? it's been a month and we can't manually pull in this fix.
@diegomura seems to be on vacation or something. But the bug was introduced in @react-pdf/renderer v2.3.0, so you can pin to v2.2.0 for now until a new version is released. By the way, @jeetiss you do not by any chance have the rights to publish new versions, do you?
Any updates about when this will get published? @diegomura
@diegomura Any updates on this fix?
This was fixed and published with @react-pdf/[email protected]. Does the fix not work for you @christopherromero? If it does, this issue could be closed.
After updating to @react-pdf/renderer
v3.0.0 I can confirm that no more crashes occur, so I think this issue can be closed.