Skip to content

Commit

Permalink
Fix bug with BlazoredModalInstance Title
Browse files Browse the repository at this point in the history
  • Loading branch information
zootius authored Mar 18, 2024
1 parent 92db30b commit fb46ef1
Showing 1 changed file with 4 additions and 3 deletions.
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; set => _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;
}
}

0 comments on commit fb46ef1

Please sign in to comment.