minPresenceAhead not working

Open
#3,586 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@JoelBrenstrum is already working on this.

Since Oct 27, 2026.

  • #3613 by @JoelBrenstrum — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript
Domain
frontend

Research direction

The reproduction is in the react-pdf REPL and needs only the Text with minPresenceAhead={200} nested in a View on a debug Page; the payload names no source files. Start by reading the earlier thread in #3233 to see what was already tried, then run the three snippets to confirm the failing case. Done means the nested case reserves the requested space like the unwrapped case does.

Written by the indexing model from the issue text.

Description

Describe the bug
minPresenceAhead does not work for text in a View that is not the first element on a page.

This is a re-opening of issue #3233, which is not fixed.

To Reproduce
Here's a minimal reproduction that demonstrates the issue in the REPL:

// FAILS
const doc = (
  <Document>
    <Page size="LETTER" style={{ padding: 30, fontSize: 12 }} debug>
      <Text>{"Contents\n".repeat(54)}</Text>

      <View>
        <Text minPresenceAhead={200}>1. Some Title</Text>

        <Text>{"Contents\n".repeat(20)}</Text>
      </View>
    </Page>
  </Document>
);

ReactPDF.render(doc);

It works the moment you remove the <View> component:

// WORKS
const doc = (
  <Document>
    <Page size="LETTER" style={{ padding: 30, fontSize: 12 }} debug>
      <Text>{"Contents\n".repeat(54)}</Text>

      {/* <View> */}
        <Text minPresenceAhead={200}>1. Some Title</Text>

        <Text>{"Contents\n".repeat(20)}</Text>
      {/* </View> */}
    </Page>
  </Document>
);

ReactPDF.render(doc);

It also works if you move the above contents into the <View>:

// WORKS
const doc = (
  <Document>
    <Page size="LETTER" style={{ padding: 30, fontSize: 12 }} debug>
      <View>
      	<Text>{"Contents\n".repeat(54)}</Text>

        <Text minPresenceAhead={200}>1. Some Title</Text>

        <Text>{"Contents\n".repeat(20)}</Text>
      </View>
    </Page>
  </Document>
);

ReactPDF.render(doc);

Expected behavior
minPresenceAhead should always reserve the requested space after the element, even if it's not the first element on a page.

Screenshots
This screenshot shows the header which should not be the last element on the page, since it specifically has minPresenceAhead set to a large value, 200:

Image
  • OS: Windows, but likely all OSes
  • Browser: Chromium
  • React-pdf version: v4.9.0 (latest currently available)
Dominant language
TypeScript
Stars
16.9k
Forks
1.3k
Avg merge
11m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diegomura/react-pdf

All issues in diegomura/react-pdf

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.