Skip to content

fix(PrintPreview): Execute writeHead even if css is null#541

Merged
tbouffard merged 2 commits into
maxGraph:mainfrom
reuse-ay:fix/page-break
Oct 5, 2024
Merged

fix(PrintPreview): Execute writeHead even if css is null#541
tbouffard merged 2 commits into
maxGraph:mainfrom
reuse-ay:fix/page-break

Conversation

@reuse-ay

@reuse-ay reuse-ay commented Oct 2, 2024

Copy link
Copy Markdown

PR Checklist

  • Addresses an existing open issue: This PR fixes some part of [BUG] PageBreak Story: "Print" does not work. #535, but doesn't close.
  • You have discussed this issue with the maintainers of maxGraph, and you are assigned to the issue.
  • The scope of the PR is small enough to review in a single session. PR targeting several issues should be split into separate PRs. Don't create large PR like Examples fixed #88.
  • I have added tests to prove my fix is effective or my feature works. This can be done in the form of automatic tests in packages/core/_tests_ or a new or altered Storybook story in packages/html/stories (an existing story may also demonstrate the change).
  • I have provided screenshot/videos to demonstrate the change. If no releavant, explain why.
  • I have added or edited necessary documentation, or no docs changes are needed.
  • The PR title follows the "Conventional Commits" guidelines.

Overview

This PR fixes some parts of #535 .

  • fix background color and tab title are not set.

In mxgraph, argument css to writeHead was allowed to be null. Please see line 45570 in mxClient.js. I fixed signature of PrintPreview.writeHead and removed null check before calling writeHead in PrintPreview.open.
スクリーンショット 2024-10-02 215432
This is a image of the tab opened after clicking 'Print' button in page break story.
スクリーンショット 2024-10-02 214129

Notes

Vertices and edges are not shown. This PR doesn't close 535.

@tbouffard tbouffard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@tbouffard tbouffard merged commit 490db9b into maxGraph:main Oct 5, 2024
@tbouffard tbouffard added the bug Something isn't working label Oct 5, 2024
@reuse-ay reuse-ay deleted the fix/page-break branch October 6, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants