Skip to content
This repository was archived by the owner on Dec 26, 2025. It is now read-only.

Conversation

@zootius
Copy link
Contributor

@zootius zootius commented Mar 18, 2024

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:

  • In MultipleModals.razor , see how you are opening a first Modal : Modal.Show<YesNoPrompt>("First Modal");
  • Modify the YesNoPrompt component, to change its own Modal Title :

protected override void OnInitialized() { BlazoredModal.SetTitle("First Modal v2"); }

Now do this:

  1. Run the sample WASM
  2. Visit the MultipleModals page, and click the "Show Modal" button
  3. See that the First Modal Title has been set to "First Modal v2" correctly
  4. Click the "Yes" button on the First Modal
  5. Click the "Cancel" button on the Second Modal
  6. 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.

Cheers, James

@zootius zootius changed the title Fix bug with BlazoredModalInstance Title Fix bug with BlazoredModalInstance SetTitle with nested modals Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant