not displaying toast content first time its shown

I have an error with sfToast not displaying the contents & title the first time its displayed.  I found the exact same question here


https://www.syncfusion.com/forums/151362/do-not-display-toast-content-in-first-time


so I followed the proposed solution which was basically to show it Synchronously, I even downloaded the example but I get an error


'sfToast does not contain a definition for Show'

looks like this has been deprecated in my version? (the latest one)


heres my code


<div class="col-lg-12 control-section toast-default-section">

    <SfToast ID="toast_default" @ref="ToastObj" Content="@ToastContent" Title="@ToastTitle" Timeout="5000" Icon="e-meeting">

        <ToastPosition X="@ToastPosition"></ToastPosition>

    </SfToast>

</div>

 

SfToast? ToastObj = new SfToast();

private string ToastPosition = "Right";

private string ToastTitle = string.Empty;

private string ToastContent = string.Empty;



ToastContent = "Venue details successfully saved";

ToastTitle = "Success !";

await this.ToastObj!.ShowAsync();


It always works perfectly the second time its activated, its content & title are always empty the first time its activated



5 Replies

PK Priyanka Karthikeyan Syncfusion Team July 2, 2024 01:24 PM UTC

Hi mark wheeler,

We have reviewed the provided code snippet and created a sample based on it. However, we didn't encounter any issues in the latest version when adding a delay before calling the ShowAsync method.

Here's an example of how you can modify the code to align it more closely with your specific scenario:

 

private async Task showOnclick()

    {

        ToastModel toastModel = new ToastModel()

            {

               Content = "Venue details successfully saved",

               Title = "Success !"

 

            };

            await Task.Delay(100);

            await this.toast.ShowAsync(toastModel);

    }

 

Sample: https://blazorplayground.syncfusion.com/rZLTXwZLJvBtKkwB

To help us understand and address the issue you're facing, could you please modify the shared sample and provide detailed steps to replicate the problem on our end? Your cooperation in providing this information will greatly assist us in resolving any challenges effectively.

Thank you for your collaboration and assistance in resolving this matter swiftly. We look forward to hearing from you.

Regards,

Priyanka K



MW mark wheeler July 2, 2024 02:41 PM UTC

your suggestion made no difference, its exactly the same



PK Priyanka Karthikeyan Syncfusion Team July 3, 2024 01:07 PM UTC

Hi mark wheeler,

The issue where the default content and title values do not show as updated initially when using SfToast is due to the component not immediately detecting property changes. This problem can be resolved by introducing a minimal time delay to allow for proper detection of property changes before the ShowAsync method is called

 

Here is a sample for reference: https://blazorplayground.syncfusion.com/LjhJDQDAJnAOjWWt

 


 

If you continue to encounter the issue, please modify the shared sample according to your scenario and provide the steps to replicate the issue. This will help us better understand the problem and provide you with a prompt solution.

Regards,

Priyanka K

 



MW mark wheeler July 24, 2024 03:46 PM UTC

this is the only way I could get it to work


 ToastContent = returnResult.ErrorList.FirstOrDefault() ?? string.Empty;

 ToastTitle = "An Error Occurred";

 await InvokeAsync(StateHasChanged);

 await Task.Delay(100);

 await this.ToastObj!.ShowAsync();



PK Priyanka Karthikeyan Syncfusion Team July 26, 2024 02:16 PM UTC

Hi mark wheeler,

We are glad that the reported issue has been resolved on your end. Please reach out to us if you require any additional assistance.

Regards,

Priyanka K


Loader.
Up arrow icon