Closed yggdrasil-tynor closed 2 years ago
It should be. What is your version of Blazorise?
Also, can you post some code snippet?
@stsrki Version 1.0.4. It used to to work before 1.0.
Codesnippet working:
public async Task Show(StrategyTestParameters parameters, Func<StrategyTestParameters, Task> onTest = null)
{
Model = parameters;
await Validations.ClearAll();
if (onTest == null)
{
OnTest = Close;
}
else
{
OnTest = async () =>
{
if (await Validations.ValidateAll())
{
using (Loading())
{
await onTest(Model);
};
Close();
}
};
}
Modal.Show();
}
Not working when awaiting the modal.
Do you call this Show
on a button click?
@stsrki yes sir
<Button Color="Color.Primary" Clicked="@OnTestClicked">Test</Button>
and the eventhandler
private Task OnTestClicked()
{
ExecuteActionAfterCheckDataChanged(async () =>
{
var tz = TimeZoneConverter.TZConvert.GetTimeZoneInfo(StrategyConfiguration.TimeZone);
var now = DateTime.UtcNow;
now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0, DateTimeKind.Utc);
var input = new StrategyTestParameters
{
From = TimeZoneInfo.ConvertTimeFromUtc(now.AddHours(-1), tz),
To = TimeZoneInfo.ConvertTimeFromUtc(now, tz),
Interval = TimeSpan.FromMinutes(5)
};
await StrategyTestModal.Show(input, async output =>
{
await TestStrategy(output);
});
});
return Task.CompletedTask;
}
Hmm, I believe that somehow with the ExecuteActionAfterCheckDataChanged
, you're breaking Blazor rendering, so the Modal internals is not triggered. Can you try adding await InvokeAsync(StateHasChanged)
somewhere after the modal.Show
?
Hmm, I believe that somehow with the
ExecuteActionAfterCheckDataChanged
, you're breaking Blazor rendering, so the Modal internals is not triggered. Can you try addingawait InvokeAsync(StateHasChanged)
somewhere after themodal.Show
?
You're completely right. I was synchronously waiting for a task in that method which broke it. Wait() instead of await. Thanks for the quick support :)
Describe the bug The Model.Show is async, but Modal's do not show when awaiting the modal. The documentation is not very clear about this?
To Reproduce Steps to reproduce the behavior: await Modal.Show() - not working Modal.Show() - working
Should the Modal.Show() not be awaited?