Skip to content

对话框服务的OnCloseAsync无法被正确触发 #3449

@gisakuya

Description

@gisakuya

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

使用对话框服务DialogService打开一个窗口,然后在窗体里又使用DialogService打开另外一个窗体,依次关闭。
第一个窗体所注册的OnCloseAsyn无法被触发。使用的版本为:8.5.5

Expected Behavior

每个注册到DialogService里的OnCloseAsyn都被正确调用

Steps To Reproduce

Index.razor

<Button OnClick="OpenDlg">点击打开弹窗</Button>

@code {
    async Task OpenDlg()
    {
        await DialogService.ShowCloseDialog<Test>("测试1", configureOption:opt=>
        {
            opt.OnCloseAsync = () =>
            {
                System.Console.WriteLine("关闭弹窗1");

                return Task.CompletedTask;
            };
        });
    }
}

Test.razor

<Button OnClick="OpenDlg">点击打开弹窗</Button>

@code {
    async Task OpenDlg()
    {
        await DialogService.ShowCloseDialog<Test>("测试2", configureOption: opt =>
        {
            opt.OnCloseAsync = () =>
            {
                System.Console.WriteLine("关闭弹窗2");

                return Task.CompletedTask;
            };
        });
    }
}

步骤:
依次点击按钮打开窗口,然后依次关闭,打印出的信息如下:
关闭弹窗2
关闭弹窗2

Exceptions (if any)

No response

.NET Version

8.0.101

Anything else?

No response

Metadata

Metadata

Assignees

Labels

need-repro-projectNeed repro projectquestionQuestion that needs to be answered

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions