Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] modal close event is causing codebehind fire start up cycle again and viewmodel to construct multi time #586

Open
paulhaggo1983 opened this issue Jul 24, 2024 · 0 comments
Labels
Bug Something isn't working Triage Issue needs to be triaged

Comments

@paulhaggo1983
Copy link

paulhaggo1983 commented Jul 24, 2024

Describe the bug
When I load the modal, the events you would expect fire. such as code behind SetParametersAsync, OnInitialized ,OnParametersSet and the linked viewmodel to fire the construct

When i close the modal, it fired them all again, have you even seen this issue please ?, we have just upgraded to .net8 Blazor Server

I call the modal with

var returnFilterData =
    await _dialogManager.OpenInterfaceAsModalAsync<IGridFilterEditor_View, GridFilterEditor_Output>("", inputs);

public async Task<O> OpenInterfaceAsModalAsync<T, O>(string title = null, IEnumerable<KeyValuePair<string, object>> inputs = null)
{
    var concreteImplementation = _serviceProvider.GetService<T>();
    var concreteType = concreteImplementation.GetType();
    return await OpenAsModalAsync<O>(concreteType, title, inputs);
}    
 public async Task<O> OpenAsModalAsync<O>(Type viewFragmentType, string title = null, IEnumerable<KeyValuePair<string, object>> inputs = null)
{
    if (inputs == null)
        inputs = new List<KeyValuePair<string, object>>();

    // Params
    var mp = new ModalParameters();
    mp.Add("ViewFragmentType", viewFragmentType);
    mp.Add("Inputs", inputs);

    // Options
    var mo = new ModalOptions { DisableBackgroundCancel = true, Position = ModalPosition.Middle , UseCustomLayout = true };

    // Open the form
    var modalForm = _modalService.Show<ModalHost_View>(title, mp, mo);
    var modalResult = await modalForm.Result;

    if (!(modalResult?.Confirmed ?? false)) return default;
    if (modalResult.Data == null) return default;
    if (modalResult.Data is not O) return default;

    return (O)modalResult.Data;
}
@paulhaggo1983 paulhaggo1983 added Bug Something isn't working Triage Issue needs to be triaged labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant