Open BenMakesGames opened 3 years ago
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:
<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)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 appearsI 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...
Hmm yes weird indeed! I'm surprised that one works and not the other!
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 (https://github.com/dotnet/MobileBlazorBindings/issues/416)
maybe there's some environment difference, though, and it'll work for you?? I've posted it here: https://github.com/BenMakesGames/MBBPrintBug
@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 )
after calling
JSRuntime.InvokeVoidAsync("print")
,<a href>
s stopped working (clicking them had no effect).rolling back to 0.5.50 resolved the issue.