radzenhq / radzen-blazor

Radzen Blazor is a set of 90+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.52k stars 786 forks source link

Dialog closes on ESC even if CloseDialogOnEsc = FALSE #1699

Closed OndrejUzovic closed 3 weeks ago

OndrejUzovic commented 3 weeks ago

If you have open the 1st dialog with CloseDialogOnEsc = FALSE and you open the 2nd dialog with CloseDialogOnEsc = TRUE, the first dialog will close on ESC too.

Here are steps to reproduce the issue:

  1. Open a dialog which has CloseDialogOnEsc = FALSE.
  2. From this dialog open the 2nd dialog which has CloseDialogOnEsc = TRUE.
  3. Close the 2nd dialog to get back to the 1st dialog.
  4. Press ESC in the first dialog => the dialog will close even CloseDialogOnEsc = FALSE.

Here is a simple code to reproduce the behavior:

@page "/"

@using Radzen;
@using Radzen.Blazor;

@inject IJSRuntime myJsRuntime
@inject DialogService myDialogService

<RadzenButton Text="Click" Click="@OnClick1" />

@code {
    private async Task OnClick1()
    {
        var dialogOptions = new DialogOptions() { CloseDialogOnEsc = false };
        await myDialogService.OpenAsync("CloseDialogOnEsc = FALSE", ds =>
        @<RadzenStack Gap="1.5rem">
            <RadzenStack Orientation="Orientation.Horizontal" Gap="0.5rem" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.SpaceBetween">
                <RadzenStack Orientation="Orientation.Horizontal">
                    <RadzenButton Text="Ok" Click="() => ds.Close(true)" Style="width: 80px;" />
                    <RadzenButton Text="Open 2nd Dialog" Click="@OnClick2" ButtonStyle="ButtonStyle.Light" />
                </RadzenStack>
            </RadzenStack>
        </RadzenStack>,
        dialogOptions);
    }

    private async Task OnClick2()
    {
        var dialogOptions = new DialogOptions() { CloseDialogOnEsc = true };
        await myDialogService.OpenAsync("CloseDialogOnEsc = TRUE", ds =>
        @<RadzenStack Gap="1.5rem">
            <RadzenStack Orientation="Orientation.Horizontal" Gap="0.5rem" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.SpaceBetween">
                <RadzenStack Orientation="Orientation.Horizontal">
                    <RadzenButton Text="Ok" Click="() => ds.Close(true)" Style="width: 80px;" />
                </RadzenStack>
            </RadzenStack>
        </RadzenStack>,
        dialogOptions);
    }
}
enchev commented 3 weeks ago

Your code works as expected in our demos: https://blazor.radzen.com/dialog

https://github.com/user-attachments/assets/202d0a5a-2cef-428f-8874-899f4379f9e8

OndrejUzovic commented 3 weeks ago

Please check the video from your demo page, I have attached. Close the second dialog using the button and then press the the ESC to close the first dialog.

DialogEscAnimation

enchev commented 3 weeks ago

I was able to reproduce it by closing the second dialog using button!