Articles in this section
Category / Section

How to prevent focus on the controls beneath the overlay of the Blazor Spinner ?

3 mins read

This article explains how to prevent focus on controls beneath the overlay of the Blazor Spinner.

You can restrict focus on controls beneath the overlay by using the jsinterop to prevent tab actions through handling the keyDown event.

Index.razor:

@using Syncfusion.Blazor.Spinner
 
<div aria-modal="true" role="dialog" tabindex="-1"> 
    <SfSpinner  @ref=_spinner @bind-Visible=@_showSpinner Label="Loading" CssClass="e-spin-overlay" ZIndex=1000 /> 
 
    <SfButton @onclick=@click>Show spinner</SfButton> 
    <SfTextBox @bind-Value=@_textInput /> 
    <p>You input is : @_textInput</p> 
</div> 
 
@code 
{ 
    SfSpinner _spinner; 
    private bool _showSpinner = false; 
    private string _textInput = string.Empty; 
 
    private async void click() 
    { 
        _showSpinner = true; 
        await jsRuntime.InvokeAsync<object>("accessDOMElement"); 
 
 
    } 
} 
 

 

Host.cshtml:

</script>
      function accessDOMElement() {
           
        window.addEventListener('keydown', handleKey);
 
        }
    function handleKey(e) {
            
       if (e.keyCode === 9) {
           e.preventDefault();
                
            }
        }
</script> 

Conclusion

We hope you enjoyed learning  how to prevent focus on the controls beneath the overlay of the Blazor spinner.

You can refer to our Blazor Spinner feature tour page to know about its other groundbreaking features, documentation, and how to quickly get started with configuration specifications. You can also explore our example to understand how to create and manipulate data.

For current customers, our Blazor components are available on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to evaluate our Blazor Spinner and other Blazor components.

If you have any questions or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied