Skip to content

Commit fddaabb

Browse files
fix break-1
1 parent b0443b9 commit fddaabb

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

packages/layout/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ats-form-react-pdf-layout",
3-
"version": "4.4.7",
3+
"version": "4.4.8",
44
"license": "MIT",
55
"description": "Resolve document component's layout",
66
"author": "Atharva System",

packages/layout/src/node/getWrap.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export const NON_WRAP_TYPES = [P.Svg, P.Note, P.Image, P.Canvas];
66
export const canCauseBlankSpace = (node, prevNode, currentChildren) => {
77
if (!('preventBlankSpace' in node.props)) return false;
88

9+
// Don't override explicit wrap: false - respect user's intent to move to next page
10+
if ('wrap' in node.props && node.props.wrap === false) return false;
11+
912
const prevNodeHasHeightOne = prevNode?.box?.height === 1;
1013
const childrenIsEmpty = currentChildren?.length === 0;
1114

@@ -31,6 +34,9 @@ const getWrap = (
3134

3235
if (!node.props) return true;
3336

37+
// Check wrap prop first - if explicitly set to false, respect that
38+
if ('wrap' in node.props && node.props.wrap === false) return false;
39+
3440
if (canCauseBlankSpace(node, prevNode, currentChildren)) return true;
3541

3642
return 'wrap' in node.props ? node.props.wrap : true;

packages/layout/src/steps/resolvePagination.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ const splitNodes = (height: number, contentArea: number, nodes: SafeNode[]) => {
152152
}
153153
}
154154

155+
// Element fits on a full page but not in remaining space and cannot wrap - move to next page
156+
if (fitsInsidePage && shouldSplit && !canWrap) {
157+
const box = Object.assign({}, child.box, { top: child.box.top - height });
158+
const props = Object.assign({}, child.props, {
159+
wrap: true,
160+
break: false,
161+
});
162+
const next = Object.assign({}, child, { box, props });
163+
164+
currentChildren.push(...futureFixedNodes);
165+
nextChildren.push(next, ...futureNodes);
166+
break;
167+
}
168+
155169
if (shouldBreak) {
156170
const box = Object.assign({}, child.box, { top: child.box.top - height });
157171
const props = Object.assign({}, child.props, {

packages/renderer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ats-form-react-pdf-renderer",
3-
"version": "4.3.7",
3+
"version": "4.3.8",
44
"license": "MIT",
55
"description": "Create PDF files on the browser and server",
66
"author": "Atharva System",
@@ -26,7 +26,7 @@
2626
"@babel/runtime": "^7.20.13",
2727
"@react-pdf/fns": "3.1.2",
2828
"@react-pdf/font": "^4.0.3",
29-
"ats-form-react-pdf-layout": "^4.4.7",
29+
"ats-form-react-pdf-layout": "^4.4.8",
3030
"@react-pdf/pdfkit": "^4.0.4",
3131
"@react-pdf/primitives": "^4.1.1",
3232
"@react-pdf/reconciler": "^1.1.4",

0 commit comments

Comments
 (0)