fix(PrintPreview): Execute writeHead even if css is null#541
Conversation
tbouffard
left a comment
There was a problem hiding this comment.
Hi and thanks for this contribution.
The analysis looks good to me and this works as explained in the PR description. ❤️
I guess that the signature of the writeHead method comes from https://github.com/typed-mxgraph/typed-mxgraph/blob/v1.0.8/lib/view/mxPrintPreview.d.ts#L360 which lacks of null support for the css parameter.
And, because of that, I also guess that the extra check in the open method was added to fix a type issue in commit 413796a.
mxGraph didn't include this null check (https://github.com/jgraph/mxgraph/blob/ff141aab158417bd866e2dfebd06c61d40773cd2/javascript/src/js/view/mxPrintPreview.js#L467-L469) for good reasons. As you mentioned, this is managed inside the writeHead method (https://github.com/jgraph/mxgraph/blob/ff141aab158417bd866e2dfebd06c61d40773cd2/javascript/src/js/view/mxPrintPreview.js#L752-L755) and not calling writeHead remove a lot of style directives that must be included within the generated page used for printing.
Tested with both
- the local dev
- by building the demo site and serving it from the root of the repository (http://127.0.0.1:8080/packages/html/dist/?path=/story/printing-pagebreaks--default) to validate there is no issue with the CSS files used in the print page.
PR Checklist
maxGraph, and you are assigned to the issue.packages/core/_tests_or a new or altered Storybook story inpackages/html/stories(an existing story may also demonstrate the change).I have added or edited necessary documentation, orno docs changes are needed.Overview
This PR fixes some parts of #535 .
In mxgraph, argument


csstowriteHeadwas allowed to be null. Please see line 45570 in mxClient.js. I fixed signature ofPrintPreview.writeHeadand removed null check before callingwriteHeadinPrintPreview.open.This is a image of the tab opened after clicking 'Print' button in page break story.
Notes
Vertices and edges are not shown. This PR doesn't close 535.