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

JSRuntime issue: after JS-invoking print, the application becomes very broken #408

Open
BenMakesGames opened this issue Sep 17, 2021 · 5 comments

Comments

@BenMakesGames
Copy link

BenMakesGames commented Sep 17, 2021

after calling JSRuntime.InvokeVoidAsync("print"), <a href>s stopped working (clicking them had no effect).

rolling back to 0.5.50 resolved the issue.

@BenMakesGames BenMakesGames changed the title issue in 0.6.69 which is not present in 0.5.0 issue in 0.6.69 which is not present in 0.5.50 Sep 17, 2021
@BenMakesGames BenMakesGames changed the title issue in 0.6.69 which is not present in 0.5.50 JSRuntime issue in 0.6.69 which is not present in 0.5.50 Sep 17, 2021
@BenMakesGames
Copy link
Author

BenMakesGames commented Sep 24, 2021

actually, I think I confused myself: this bug exists in 0.5.50 as well, however if you use Ctrl+P to print page, there are no ill side effects.

view:

<button @onclick="DoPrint">Print</button>

code-behind:

        private async Task DoPrint()
        {
            await JS.InvokeVoidAsync("print");
        }

I also tried the suggestion here: https://stackoverflow.com/questions/67206330/window-print-in-blazor-wasm where the print method is moved into a custom JS function (not sure why that would matter, but I tried it, anyway), and the problem persisted.

I also-also tried making DoPrint not be async or await, but that didn't change anything, either.

I am able to JS.InvokeVoidAsync other JS methods with no ill effect (I made a ScrollToBottom method to scroll a div after content is added, and that doesn't cause any problems).

again, using Ctrl+P to print works fine; using JS.InvokeVoidAsync to do it, however, breaks the app in the following ways:

  • clicking any <a href...> fails to work (in my app's header, I have one with a URL in it, and another with javascript:history.go(-1), and both work before the print attempt, and both fail after)
  • I happen to be using Blazored.Modals, and clicking a button which should open one of these partially works: the page is updated so that scrolling is no longer possible (it adds styling rules to the <body> tag which I can see), but the modal never appears
  • there are no errors in the debugging console
  • when running with the debugger attached, it doesn't catch anything

@BenMakesGames BenMakesGames changed the title JSRuntime issue in 0.6.69 which is not present in 0.5.50 JSRuntime issue: after JS-invoking print, the application becomes very broken Sep 24, 2021
@BenMakesGames
Copy link
Author

BenMakesGames commented Sep 24, 2021

I just tried changing the button to instead be:

<a class="button" href="javascript:print();">Print</a>

and that works, without any ill side-effects!

so weird...

@Eilon
Copy link
Member

Eilon commented Sep 24, 2021

Hmm yes weird indeed! I'm surprised that one works and not the other!

@BenMakesGames
Copy link
Author

BenMakesGames commented Sep 24, 2021

I've attempted to create a minimum project which will show the issue, however I'm unable to test it because I'm getting that "can't reach this page" issue I mentioned in the other issue (#416)

maybe there's some environment difference, though, and it'll work for you?? I've posted it here: https://github.com/BenMakesGames/MBBPrintBug

@BenMakesGames
Copy link
Author

BenMakesGames commented Oct 6, 2021

@Eilon I have a minimum project demonstrating the issue (now working, thanks to your hint about explicitly including WebView2), here: https://github.com/BenMakesGames/MBBPrintBug

I've added some notes on the print page about how to reproduce and see the issue. (seen here: https://github.com/BenMakesGames/MBBPrintBug/blob/main/PrintBug/Pages/Print.razor )

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

No branches or pull requests

2 participants