Skip to content

Commit

Permalink
Added check for SetFocus for disabling it when ActivateFocusTrap is s…
Browse files Browse the repository at this point in the history
…et to false. (#530)

As if you have opened multiple modals and close top modal scroll position goes to the top.
The only way to stop this behavior in previus version was by using CustomLayout.
With this change you only need to set ModalOption>ActivateFocusTrap to false.

Co-authored-by: Andreas Winges <[email protected]>
Co-authored-by: Chris Sainty <[email protected]>
  • Loading branch information
3 people authored Feb 19, 2024
1 parent 898e88d commit c9b2118
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Blazored.Modal/BlazoredModalInstance.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (_setFocus)
{
if (FocusTrap is not null)
if (FocusTrap is not null
&& ActivateFocusTrap)
{
await FocusTrap.SetFocus();
}
Expand Down

0 comments on commit c9b2118

Please sign in to comment.