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

Fix bug with BlazoredModalInstance SetTitle with nested modals #572

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Blazored.Modal/BlazoredModalInstance.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

[Parameter, EditorRequired] public RenderFragment Content { get; set; } = default!;
[Parameter, EditorRequired] public ModalOptions Options { get; set; } = default!;
[Parameter] public string? Title { get; set; }
[Parameter] public string? Title { get => _title; init => _title ??= value; }

Check warning on line 14 in src/Blazored.Modal/BlazoredModalInstance.razor.cs

View workflow job for this annotation

GitHub Actions / Build and test

Component parameter 'Blazored.Modal.BlazoredModalInstance.Title' should be auto property

Check warning on line 14 in src/Blazored.Modal/BlazoredModalInstance.razor.cs

View workflow job for this annotation

GitHub Actions / Build and test

Component parameter 'Blazored.Modal.BlazoredModalInstance.Title' should be auto property
[Parameter] public Guid Id { get; set; }

private string? Position { get; set; }
Expand All @@ -32,6 +32,7 @@
private bool _setFocus;
private bool _disableNextRender;
private bool _listenToBackgroundClicks;
private string? _title { get; set; }

// Temporarily add a tabindex of -1 to the close button so it doesn't get selected as the first element by activateFocusTrap
private readonly Dictionary<string, object> _closeBtnAttributes = new() { { "tabindex", "-1" } };
Expand Down Expand Up @@ -78,7 +79,7 @@
/// <param name="title">Text to display as the title of the modal</param>
public void SetTitle(string title)
{
Title = title;
_title = title;
StateHasChanged();
}

Expand Down Expand Up @@ -362,4 +363,4 @@

void IDisposable.Dispose()
=> Parent.OnModalClosed -= AttemptFocus;
}
}
Loading