Visit the MultipleModals page, and click the "Show Modal" button
See that the First Modal Title has been set to "First Modal v2" correctly
Click the "Yes" button on the First Modal
Click the "Cancel" button on the Second Modal
You will see that the First Modal has now lost its "First Modal v2" title, and fallen back to the original title of "First Modal".
I believe this is due to the original Title parameter being automatically reset by Blazor's RenderFragment mechanism.
So, my fix in this pull request is to use a private _title variable in the modal instance, which is written to once only by the Parameter, and subsequently only modified by use of the SetTitle method. Please let me know what you think.
I have found a problem with raising nested modals on a page, specifically where the title of the "parent" modal has been set with
SetTitle()
.You can reproduce the problem by trying the following in your Blazored.Modal BlazorWebAssembly sample project:
MultipleModals.razor
, see how you are opening a first Modal :Modal.Show<YesNoPrompt>("First Modal");
YesNoPrompt
component, to change its own Modal Title :protected override void OnInitialized() { BlazoredModal.SetTitle("First Modal v2"); }
Now do this:
I believe this is due to the original
Title
parameter being automatically reset by Blazor's RenderFragment mechanism.So, my fix in this pull request is to use a private
_title
variable in the modal instance, which is written to once only by the Parameter, and subsequently only modified by use of theSetTitle
method. Please let me know what you think.Cheers, James