From c9b2118cd9d1c3ad0133f94a5cd29ac96a33953c Mon Sep 17 00:00:00 2001 From: 00anwi Date: Tue, 20 Feb 2024 00:54:37 +0100 Subject: [PATCH] Added check for SetFocus for disabling it when ActivateFocusTrap is set 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 Co-authored-by: Chris Sainty --- src/Blazored.Modal/BlazoredModalInstance.razor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Blazored.Modal/BlazoredModalInstance.razor.cs b/src/Blazored.Modal/BlazoredModalInstance.razor.cs index a094585..bca1b08 100644 --- a/src/Blazored.Modal/BlazoredModalInstance.razor.cs +++ b/src/Blazored.Modal/BlazoredModalInstance.razor.cs @@ -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(); }