We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: Blazor |
Control: Spinner

This article explains how to prevent the focus to the control beneath the overlay of Blazor Spinner

 

You can restrict focus to the other controls beneath the overlay can be achieved by using the jsinterop by preventing the tab action handling 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> 

View Sample in GitHub

 

Refer to our documentation and online samples for more features. If you have any queries, please let us   know in the comments below. You can also contact us through our Support forum or Support ticket. We are happy to assist you!

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile