Skip to content
This repository was archived by the owner on Dec 26, 2025. It is now read-only.
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 @@ public partial class BlazoredModalInstance : IDisposable

[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; }
[Parameter] public Guid Id { get; set; }

private string? Position { get; set; }
Expand All @@ -32,6 +32,7 @@ public partial class BlazoredModalInstance : IDisposable
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 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
/// <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 @@ private void StopListeningToBackgroundClick()

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