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

[Bug] [Chrome] - Print is triggering in Tab 1, Tab 2 Blank Page #745

Open
rubysky17 opened this issue Oct 1, 2024 · 8 comments
Open

[Bug] [Chrome] - Print is triggering in Tab 1, Tab 2 Blank Page #745

rubysky17 opened this issue Oct 1, 2024 · 8 comments

Comments

@rubysky17
Copy link

  • I have a case with my behaviour
  • Step 1: Open link: https://codesandbox.io/p/sandbox/react-to-print-uhwxj?file=%2Findex.js
  • Step 2: Click print any Button print and Have popup preview
  • Step 3: Open new tab (please dont close popup preview in old tab)
  • Step 4: Paste link again.
  • Error: link in the new tab the same origin with old tab return blank page. Note: link in the iframe will be return blank if the print process not finish.
@MatthewHerbst
Copy link
Owner

This is super interesting, thanks! I'm able to reproduce with the local examples:

If I skip the printing I can open http://localhost:8080/ in two tabs no problem.

This is for sure an upstream issue with Chrome. I wouldn't be surprised if this was in some ways intended behavior due to the single-threaded nature of JS, not sure though, will research!

@MatthewHerbst
Copy link
Owner

Some additional testing:

  • Safari: this bug is not possible since Safari does not allow interaction with other tabs or windows when the print preview is open
  • Firefox: Firefox properly allows opening a print preview from each tab independently

@MatthewHerbst
Copy link
Owner

MatthewHerbst commented Oct 1, 2024

Something else strange: if I do cmd+p to print there is no issue with multiple tabs in Chrome, so this is likely related to using window.print somehow

@MatthewHerbst
Copy link
Owner

Minimum reproducible example:

<!DOCTYPE html>
<html>
  <body>
    <script>
      function handlePrintOnClick() {
        window.print();
      }
    </script>
    <button onclick="handlePrintOnClick()">Trigger Print</button>
  </body>
</html>

@MatthewHerbst
Copy link
Owner

This seems to be a related Chromium issue from a few years ago that was fixed. Maybe it has regressed again in a slightly different fashion

@MatthewHerbst
Copy link
Owner

One additional thing: there is some scope to this, since the issue does not occur if you try to open the new tab in an incognito window

@MatthewHerbst
Copy link
Owner

I've reported this as a new issue, we'll see what they say: https://issues.chromium.org/issues/370543477

@rubysky17
Copy link
Author

i see that error when use the same origin and iframe tag. The window.print() function not work with me and i think that not is error from library. I'll wait reply from that issue. Thanks you a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants