Hello Dimo,
That is good to know for future reference, if I find myself in the same situation again. The reason I have omitted the DialogButtons is because I needed to use FormButtons inside of the Dialog, which didn't appear usable from the DialogButtons Tag.
Cheers!
David Lamonaca.
Hi David,
The Dialog expects to have action buttons at the bottom and their lack is causing the undesired behavior.
The Dialog action buttons represent the main feature of the Dialog, which distinguishes it from the Window. If you don't need them, you might as well switch to a modal non-resizable non-draggable Window.
Regards,
Dimo
Progress Telerik
Hello Dimo,
That scenario is very similar. However, I am using a TelerikDialog instead of a TelerikWindow.
Cheers!
David Lamonaca.
Hi David,
Is this your scenario - Grid popup editing with a custom modal Window opened from the popup edit form
I can't tab outside the second modal, no matter how many times I open it.
Regards,
Dimo
Progress Telerik
Greetings Dimo,
I see from the most recent comment that a planned released to fix this was set for early March.
"Yes, we aim to include this behavior in the next release 4.1. in early March."
I am unsure if this change had made it through to that release or not. However, I am experience the same issue other have been facing. a key difference being that the content behind the modal is only accessible on the second open of the modal.
I am using a TelerikGrid which opens a TelerikForm and inside that form I have a button that opens a modal. If the user opens the modal inside the form the first time, everything works as attended, but if they close the modal and open it again they are able to tab out of the modal and into the TelerikForm.
As can be seen in the provided image, my modal has ended up behind the TelerikForm.
Cheers!
David Lamonaca.
Hi Alexander and everyone,
Yes, we aim to include this behavior in the next release 4.1. in early March.
Regards,
Dimo
Progress Telerik
Hello all,
While we implement this feature, consider the following workaround. It uses JavaScript to prevent focus behind the modal Window. It can rely on a specific parent container or work with all elements outside a Window.
@inject IJSRuntime js
<div id="container">
<TelerikButton OnClick="@ShowWindow">Show Window</TelerikButton>
<p>some focusable elements here:</p>
<div contenteditable="true" tabindex="1">custom focusable element</div>
<p><input /></p>
<p><a href="#">link</a></p>
</div>
<TelerikWindow Visible="@WindowVisible"
VisibleChanged="@WindowVisibleChanged"
Centered="true"
Modal="true">
<WindowActions>
<WindowAction Name="Close" />
</WindowActions>
<WindowTitle>
Window title
</WindowTitle>
<WindowContent>
<p>Focus outside the Window is now disabled.</p>
<p>If you want to experiment while the Window is open:</p>
<TelerikButton OnClick="@PreventFocus">Prevent Focus</TelerikButton>
<TelerikButton OnClick="@RestoreFocus">Restore Focus</TelerikButton>
</WindowContent>
</TelerikWindow>
@* Move this script to a proper location in a production app *@
<script suppress-error="BL9992">function preventFocus(containerSelector) {
processTabindex(containerSelector, "tabindex", "back_tabindex");
}
function restoreFocus(containerSelector) {
processTabindex(containerSelector, "back_tabindex", "tabindex");
}
function processTabindex(containerSelector, attr, backAttr) {
// workaround for a specific container
//var container = document.querySelector(containerSelector);
//var elements = container.querySelectorAll("input, textarea, a, button, [tabindex]");
// OR
// workaround for all elements outside a Window
var elements = document.querySelectorAll(":not(.k-window) input, :not(.k-window) textarea, :not(.k-window) a, :not(.k-window) button, :not(.k-window) [tabindex]");
elements.forEach(el => {
if (attr == "back_tabindex") {
// restoring saved tabindex, we remove tabindex -1
el.removeAttribute("tabindex");
}
var tabindex = el.getAttribute(attr);
if (tabindex != null) {
el.setAttribute(backAttr, tabindex);
}
if (attr == "tabindex") {
// preventing focus, we set tabindex -1 to everything
el.setAttribute(attr, "-1");
} else {
// restoring saved tabindex, we remove the temporary attribute
el.removeAttribute(attr);
}
});
}</script>
@code {
bool WindowVisible { get; set; }
async Task ShowWindow()
{
WindowVisible = true;
await PreventFocus();
}
async Task WindowVisibleChanged(bool newVisible)
{
WindowVisible = newVisible;
if (WindowVisible)
{
await PreventFocus();
}
else
{
await RestoreFocus();
}
}
async Task PreventFocus()
{
await js.InvokeVoidAsync("preventFocus", "#container");
}
async Task RestoreFocus()
{
await js.InvokeVoidAsync("restoreFocus", "#container");
}
}
Regards,
Dimo
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.