@@ -23,7 +23,7 @@ public partial class Dialog : IDisposable
23
23
[ NotNull ]
24
24
private Func < Task > ? _onCloseAsync = null ;
25
25
26
- private readonly Dictionary < Dictionary < string , object > , ( bool IsKeyboard , bool IsBackdrop ) > DialogParameters = [ ] ;
26
+ private readonly Dictionary < Dictionary < string , object > , ( bool IsKeyboard , bool IsBackdrop , Func < Task > ? OnCloseCallback ) > DialogParameters = [ ] ;
27
27
private Dictionary < string , object > ? _currentParameter ;
28
28
private bool _isKeyboard = false ;
29
29
private bool _isBackdrop = false ;
@@ -72,16 +72,14 @@ private async Task Show(DialogOption option)
72
72
73
73
_onCloseAsync = async ( ) =>
74
74
{
75
- // Callback OnCloseAsync
76
- if ( option . OnCloseAsync != null )
77
- {
78
- await option . OnCloseAsync ( ) ;
79
- }
80
-
81
75
// Remove current DialogParameter
82
76
if ( _currentParameter != null )
83
77
{
84
- DialogParameters . Remove ( _currentParameter ) ;
78
+ DialogParameters . Remove ( _currentParameter , out var v ) ;
79
+ if ( v . OnCloseCallback != null )
80
+ {
81
+ await v . OnCloseCallback ( ) ;
82
+ }
85
83
86
84
// Support for multiple dialogs
87
85
var p = DialogParameters . LastOrDefault ( ) ;
@@ -162,7 +160,7 @@ private async Task Show(DialogOption option)
162
160
_currentParameter = parameters ;
163
161
164
162
// Add ModalDialog to the container
165
- DialogParameters . Add ( parameters , ( _isKeyboard , _isBackdrop ) ) ;
163
+ DialogParameters . Add ( parameters , ( _isKeyboard , _isBackdrop , option . OnCloseAsync ) ) ;
166
164
await InvokeAsync ( StateHasChanged ) ;
167
165
}
168
166
0 commit comments