Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Content Causes Flex Items to Overflow on Wrapping Page #2922

Open
berberi opened this issue Oct 30, 2024 · 0 comments
Open

Fixed Content Causes Flex Items to Overflow on Wrapping Page #2922

berberi opened this issue Oct 30, 2024 · 0 comments

Comments

@berberi
Copy link

berberi commented Oct 30, 2024

Describe the bug
I have a few paragraphs of text that wrap into multiple pages:
image

(borders added to make the issue clearer in the next screenshot)

But then if I add some fixed content to the page, like a footer, each of those flex items seems to shrink to account for the fixed content, so they no longer fit the text within them, causing the text to overflow the containers (you can see the text breaking out of the boxes below, now with the new footer added):

image

The problem gets more obvious if the fixed content is larger:
image

Alternative view with debug turned on on the text items:

image

To Reproduce
REPL link here, which is just this code:

const MyText = ({children}) => (
  <Text style={{border: '1pt solid black' }}>{children}</Text>
)

const Example = () => (
  <Document>
    <Page style={{ padding: 24, gap: 30 }}>
      <View style={{ flex: 1, gap: 24 }}>
      	<MyText>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dapibus, massa a feugiat pretium, nisi lectus pulvinar purus, quis elementum ipsum urna eget leo. Etiam eros lacus, maximus ac scelerisque eu, vulputate a nulla. Etiam sagittis in nisl ut tempus. Suspendisse sed ipsum dolor. Praesent rutrum sollicitudin nunc, et posuere tellus dapibus in. Donec lobortis nisi quis dui maximus faucibus. Donec fringilla lectus vitae mi lacinia, ac bibendum ante mollis. Duis sit amet vulputate lectus, ac venenatis ligula.</MyText>
      	<MyText>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dapibus, massa a feugiat pretium, nisi lectus pulvinar purus, quis elementum ipsum urna eget leo. Etiam eros lacus, maximus ac scelerisque eu, vulputate a nulla. Etiam sagittis in nisl ut tempus. Suspendisse sed ipsum dolor. Praesent rutrum sollicitudin nunc, et posuere tellus dapibus in. Donec lobortis nisi quis dui maximus faucibus. Donec fringilla lectus vitae mi lacinia, ac bibendum ante mollis. Duis sit amet vulputate lectus, ac venenatis ligula.</MyText>
      	<MyText>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dapibus, massa a feugiat pretium, nisi lectus pulvinar purus, quis elementum ipsum urna eget leo. Etiam eros lacus, maximus ac scelerisque eu, vulputate a nulla. Etiam sagittis in nisl ut tempus. Suspendisse sed ipsum dolor. Praesent rutrum sollicitudin nunc, et posuere tellus dapibus in. Donec lobortis nisi quis dui maximus faucibus. Donec fringilla lectus vitae mi lacinia, ac bibendum ante mollis. Duis sit amet vulputate lectus, ac venenatis ligula.</MyText>
      	<MyText>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dapibus, massa a feugiat pretium, nisi lectus pulvinar purus, quis elementum ipsum urna eget leo. Etiam eros lacus, maximus ac scelerisque eu, vulputate a nulla. Etiam sagittis in nisl ut tempus. Suspendisse sed ipsum dolor. Praesent rutrum sollicitudin nunc, et posuere tellus dapibus in. Donec lobortis nisi quis dui maximus faucibus. Donec fringilla lectus vitae mi lacinia, ac bibendum ante mollis. Duis sit amet vulputate lectus, ac venenatis ligula.</MyText>
      	<MyText>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dapibus, massa a feugiat pretium, nisi lectus pulvinar purus, quis elementum ipsum urna eget leo. Etiam eros lacus, maximus ac scelerisque eu, vulputate a nulla. Etiam sagittis in nisl ut tempus. Suspendisse sed ipsum dolor. Praesent rutrum sollicitudin nunc, et posuere tellus dapibus in. Donec lobortis nisi quis dui maximus faucibus. Donec fringilla lectus vitae mi lacinia, ac bibendum ante mollis. Duis sit amet vulputate lectus, ac venenatis ligula.</MyText>
      	<MyText>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dapibus, massa a feugiat pretium, nisi lectus pulvinar purus, quis elementum ipsum urna eget leo. Etiam eros lacus, maximus ac scelerisque eu, vulputate a nulla. Etiam sagittis in nisl ut tempus. Suspendisse sed ipsum dolor. Praesent rutrum sollicitudin nunc, et posuere tellus dapibus in. Donec lobortis nisi quis dui maximus faucibus. Donec fringilla lectus vitae mi lacinia, ac bibendum ante mollis. Duis sit amet vulputate lectus, ac venenatis ligula.</MyText>
      </View>
      
      <View fixed>
      	<MyText>Fixed Footer</MyText>
      </View>
    </Page>
  </Document>
)

ReactPDF.render(<Example />);

The "flex: 1" on the content is to ensure the footer is pushed to the bottom of the page (see page 2)

Expected behavior
Expected items not to shrink, and/or text not to break out of containers, when adding fixed content to the page.

I looked around and saw several similar-ish issues related to flex items, overflowing text, and page wrapping, but I didn't see something with an obvious solution for this example.

Is there some style property I'm missing on the text to prevent it from overflowing like this, to ensure the flex items stay large enough to fit the text within them?

Screenshots
See above

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • React-pdf version: 4.0.0 (in REPL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant