Async initialization of dialog when displayed

2 Answers 466 Views
Dialog
Robert
Top achievements
Rank 1
Iron
Veteran
Robert asked on 14 Jan 2022, 12:44 PM

The dialog doesn't seem to be properly initialized in this scenario.

REPL: Example

2 Answers, 1 is accepted

Sort by
0
Hristian Stefanov
Telerik team
answered on 19 Jan 2022, 09:00 AM

Hi Robert,

The described problem occurs because the async data comes after showing the dialog. You need to redraw the component here by using the Dialog Refresh() method.

I have modified the example with the above approach. Please run and test this REPL link.

Regards,
Hristian Stefanov
Progress Telerik

Learn about the important changes coming in UI for Blazor 3.0 in January 2022!
0
Haiqiang
Top achievements
Rank 1
Iron
answered on 14 Feb 2022, 09:11 AM | edited on 14 Feb 2022, 12:51 PM

Hi Telerik,

I have a similar async problem with Dialog, please check my scenario in this example link. In this scenario I expecting to see the dialog after 2 seconds when you press the button 'Show', so seems that Dialog doesn't like to be called asynchronously and leads to my question: is there any async-oriented call to show the Dialog or any workaround to make it work in this kind of scenario? Thanks in advance.

Update:

I've solved the problem by replacing the line 29 from DialogRef.Refresh() to StateHasChanged() so the UI is manually refreshed when the async Task finishes

BR

Tags
Dialog
Asked by
Robert
Top achievements
Rank 1
Iron
Veteran
Answers by
Hristian Stefanov
Telerik team
Haiqiang
Top achievements
Rank 1
Iron
Share this question
or