@@ -23,7 +23,7 @@ public partial class Dialog : IDisposable
2323 [ NotNull ]
2424 private Func < Task > ? _onCloseAsync = null ;
2525
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 = [ ] ;
2727 private Dictionary < string , object > ? _currentParameter ;
2828 private bool _isKeyboard = false ;
2929 private bool _isBackdrop = false ;
@@ -72,16 +72,14 @@ private async Task Show(DialogOption option)
7272
7373 _onCloseAsync = async ( ) =>
7474 {
75- // Callback OnCloseAsync
76- if ( option . OnCloseAsync != null )
77- {
78- await option . OnCloseAsync ( ) ;
79- }
80-
8175 // Remove current DialogParameter
8276 if ( _currentParameter != null )
8377 {
84- DialogParameters . Remove ( _currentParameter ) ;
78+ DialogParameters . Remove ( _currentParameter , out var v ) ;
79+ if ( v . OnCloseCallback != null )
80+ {
81+ await v . OnCloseCallback ( ) ;
82+ }
8583
8684 // Support for multiple dialogs
8785 var p = DialogParameters . LastOrDefault ( ) ;
@@ -162,7 +160,7 @@ private async Task Show(DialogOption option)
162160 _currentParameter = parameters ;
163161
164162 // Add ModalDialog to the container
165- DialogParameters . Add ( parameters , ( _isKeyboard , _isBackdrop ) ) ;
163+ DialogParameters . Add ( parameters , ( _isKeyboard , _isBackdrop , option . OnCloseAsync ) ) ;
166164 await InvokeAsync ( StateHasChanged ) ;
167165 }
168166
0 commit comments