How to prevent focus on the controls beneath the overlay of the Blazor 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>
Conclusion
I 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 feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!