minPresenceAhead not working
Maintainers usually reply within 1 day
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:
- 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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diegomura/react-pdf
-
@react-pdf/font: published types import fontkit, but @types/fontkit is only a devDependencyPossibly taken @iliev-blnk claimed this 14 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Unable to set flexShrink to 0Possibly taken @adarshsm claimed this 14 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
@react-pdf/hyphenate: import-only exports map throws ERR_PACKAGE_PATH_NOT_EXPORTED in require-condition resolvers (every tsx script loading renderer >= 4.7 crashes)Possibly taken @cruzdanilo claimed this 43 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
diegomura/react-pdf#3551 · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
All issues in diegomura/react-pdf
Similar issues
-
Chip source filter and denial markers miss Storage rows when a Storage activity source is pickedOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
omdsh-dev/DSH-better-sidebar#1141 ·
Maintainers usually reply within 2 days
-
desktop linux photos
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Cleanup SetupPossibly taken @AlexanderKaran claimed this today. Opendocumentation enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
e18e/framework-tracker#769 ·
Maintainers usually reply within 1 day
-
bug v2
Difficulty 1/5 Under an hour Newbie friendliness 88/100
modelcontextprotocol/servers#5483 ·
Maintainers usually reply within 1 day