Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Chrome Print Preview Fix #1030

Merged
merged 2 commits into from
Jul 1, 2019
Merged

Conversation

mickr
Copy link
Contributor

@mickr mickr commented Jul 1, 2019

  • Add listener that is fired once the iframe has loaded it's content for printing.
    This enables chrome to show an accurate print preview.

@boxcla
Copy link

boxcla commented Jul 1, 2019

Verified that @mickr has signed the CLA. Thanks for the pull request!

@mickr mickr changed the title Fix(COXP-4819): Chrome Print Preview Fix Fix(imageViewer): Chrome Print Preview Fix Jul 1, 2019
jeremypress
jeremypress previously approved these changes Jul 1, 2019
@mickr mickr changed the title Fix(imageViewer): Chrome Print Preview Fix Fix: Chrome Print Preview Fix Jul 1, 2019
} else {
this.printframe.contentWindow.print();
// Chrome will show preview from iframe before the content is loaded.
this.printframe.addEventListener('load', defaultPrintHandler);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can there be a situation where the frame has already fired its load event by the time this code executes? Such as if the content is cached? If so, does print still work?

Copy link
Contributor

Choose a reason for hiding this comment

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

This code is from a few years ago, but I wonder if we could streamline the code to wait for the 'load' event for all browsers before attempting the print?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am updating the code as @ConradJChan suggested for all browsers.

@mickr mickr force-pushed the COXP-4819-Chrome-print-preview branch from 065a5e5 to 724242b Compare July 1, 2019 17:49
mickr added 2 commits July 1, 2019 13:51
* Add listener that is fired once the iframe has loaded it's content for printing.
  This enables chrome to show an accurate print preview.
Refactor code so that all print calls are async on the load event and the event handler is added earlier in the instantiation process.
@mickr mickr force-pushed the COXP-4819-Chrome-print-preview branch from 6e18ab1 to 197815b Compare July 1, 2019 20:52
@mickr mickr merged commit 0fee384 into box:master Jul 1, 2019
@mickr mickr deleted the COXP-4819-Chrome-print-preview branch July 1, 2019 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants