-
-
Notifications
You must be signed in to change notification settings - Fork 363
fix(Dialog): not trigger OnCloseAsync multiple dialog #6339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideRefactors the Dialog component to store each dialog’s OnCloseAsync callback alongside its display parameters and invoke it only after the specific dialog is removed, ensuring callbacks are not triggered multiple times when multiple dialogs are open. Sequence diagram for OnCloseAsync invocation with multiple dialogssequenceDiagram
participant User as actor User
participant Dialog
participant DialogParameters
participant OnCloseCallback as OnCloseAsync Callback
User->>Dialog: Close a dialog
Dialog->>DialogParameters: Remove _currentParameter
DialogParameters-->>Dialog: Return (IsKeyboard, IsBackdrop, OnCloseCallback)
alt OnCloseCallback exists
Dialog->>OnCloseCallback: Invoke OnCloseCallback()
end
Dialog->>DialogParameters: Get last dialog (if any)
Dialog->>Dialog: Update _currentParameter, _isKeyboard, _isBackdrop
Dialog->>Dialog: StateHasChanged()
Class diagram for updated DialogParameters structure in Dialog componentclassDiagram
class Dialog {
- Dictionary<Dictionary<string, object>, (bool IsKeyboard, bool IsBackdrop, Func<Task>? OnCloseCallback)> DialogParameters
- Dictionary<string, object>? _currentParameter
- bool _isKeyboard
- bool _isBackdrop
- Func<Task>? _onCloseAsync
+ Task Show(DialogOption option)
}
class DialogOption {
+ Func<Task>? OnCloseAsync
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ArgoZhang - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs:78` </location>
<code_context>
if (_currentParameter != null)
{
- DialogParameters.Remove(_currentParameter);
+ DialogParameters.Remove(_currentParameter, out var v);
+ if (v.OnCloseCallback != null)
+ {
+ await v.OnCloseCallback();
</code_context>
<issue_to_address>
Potential null reference if Remove fails to find the key.
Consider logging a warning if _currentParameter is not found in DialogParameters, as Remove returning false may indicate unexpected behavior.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
if (_currentParameter != null)
{
DialogParameters.Remove(_currentParameter, out var v);
if (v.OnCloseCallback != null)
{
await v.OnCloseCallback();
}
=======
if (_currentParameter != null)
{
if (DialogParameters.Remove(_currentParameter, out var v))
{
if (v.OnCloseCallback != null)
{
await v.OnCloseCallback();
}
}
else
{
// Log a warning if _currentParameter is not found
Logger?.LogWarning($"DialogParameters did not contain the key: {_currentParameter}");
}
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6339 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 717 717
Lines 31573 31571 -2
Branches 4461 4461
=========================================
- Hits 31573 31571 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6332
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Fix OnCloseAsync callback invocation for multiple stacked dialogs by storing callbacks in the dialog parameters and invoking them upon each dialog removal.
Bug Fixes:
Enhancements: