-
I'm trying to create toasts with a top action that basically acts as an undo button for the thing that triggered the toasts. However, clicking the action seems to redirect me back to the home page or more specifically, back to https://localhost:7077/# Here's a significantly slimmed down version of the code I have (that I used to test this issue), but you'll see there's nothing fancy here. @page "/"
@inject IToastService service
@rendermode InteractiveServer
<PageTitle>Home</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.
<FluentButton OnClick=test >Test</FluentButton>
@code {
private void test() {
Console.WriteLine("hi");
service.ShowSuccess("test", 10_000_000, "Do thing", EventCallback.Factory.Create<ToastResult>(this, test));
}
} I also have How can I avoid this redirect? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
The last parameter is the callback function you want to be called when the action is clicked. See https://fluentui-blazor.net/Toast#toast with sync and async example for the general ShowToast method where a message is logged |
Beta Was this translation helpful? Give feedback.
Ok, I got the solution running.
The issue is caused by interactivity not being fully available in the app on the toast page, even though you've specified a rendermode on the page itself. If you change line 31 in
App.razor
to<Routes @rendermode=InteractiveServer />
It starts working like it should.So my conclusion would be toast/SSR do not play nice together. Just adding the rendermode to the provider is not enough