Skip to content

Commit

Permalink
fix: page wrap=false not preventing page from breaking (#2034)
Browse files Browse the repository at this point in the history
Co-authored-by: Samantha Fornari <[email protected]>
  • Loading branch information
imatwork and Samantha Fornari authored Nov 7, 2022
1 parent 2ebba93 commit 992b91b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-eggs-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-pdf/layout': patch
---

fix: page wrap=false not preventing page from breaking
2 changes: 2 additions & 0 deletions packages/layout/src/steps/resolvePagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ const dissocSubPageData = page => {
const paginate = (page, pageNumber, fontStore) => {
if (!page) return [];

if (page.props?.wrap === false) return [page];

let splittedPage = splitPage(page, pageNumber, fontStore);

const pages = [splittedPage[0]];
Expand Down
32 changes: 32 additions & 0 deletions packages/layout/tests/steps/resolvePagination.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,36 @@ describe('pagination step', () => {
expect(view2.box.height).toBe(60);
expect(view3.box.height).toBe(10);
});

test('should not wrap page with false wrap prop', () => {
const root = {
type: 'DOCUMENT',
children: [
{
type: 'PAGE',
box: {},
style: {
width: 5,
height: 60,
},
props: {
wrap: false,
},
children: [
{
type: 'VIEW',
box: {},
style: { height: 130 },
props: {},
children: [],
},
],
},
],
};

const layout = calcLayout(root);

expect(layout.children.length).toBe(1);
});
});

0 comments on commit 992b91b

Please sign in to comment.