Conversation
Reviewer's GuideIntroduces a new ICloseable interface to standardize close-related callbacks across dialog and modal components, wires Dialog and Modal to use the new pre-close callback, adds a regression test for the new behavior, and simplifies test infrastructure cleanup by removing a mock environment and properly awaiting async disposal. Sequence diagram for dialog closing with new OnClosingAsync callbacksequenceDiagram
actor User
participant Dialog
participant Modal
participant ClientCode_OnClosingAsync
User->>Dialog: Open dialog with DialogOption
Dialog->>Dialog: Show(option)
Dialog->>Modal: Set OnClosingAsync = option.OnClosingAsync
Dialog->>Modal: Set OnCloseAsync = option.OnCloseAsync
User->>Modal: Attempt to close
Modal->>ClientCode_OnClosingAsync: OnClosingAsync()
ClientCode_OnClosingAsync-->>Modal: bool canClose
alt canClose is true
Modal->>Modal: Proceed with close logic
Modal->>ClientCode_OnClosingAsync: OnCloseAsync()
Modal-->>User: Dialog closed
else canClose is false
Modal-->>User: Close cancelled, dialog remains open
end
Class diagram for new ICloseable interface and implementing componentsclassDiagram
direction LR
class ICloseable {
<<interface>>
+Func~Task~ OnCloseAsync
+Func~Task~1~bool~~ OnClosingAsync
}
class Modal {
+Func~Task~ OnShownAsync
+Func~Task~ OnCloseAsync
+Func~Task~1~bool~~ OnClosingAsync
}
class DialogOption {
+Modal? Modal
+Func~Task~ OnCloseAsync
+Func~Task~1~bool~~ OnClosingAsync
+bool IsKeyboard
+bool IsBackdrop
+bool IsFade
}
class Dialog {
-Modal _modal
-Func~Task~ _onShownAsync
-Func~Task~ _onCloseAsync
-Func~Task~1~bool~~ _onClosingAsync
+Task Show(DialogOption option)
}
ICloseable <|.. Modal
ICloseable <|.. DialogOption
Dialog --> Modal : uses
Dialog --> DialogOption : configures_from
DialogOption --> Modal : configuration_applied_via_Dialog
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.
Hey - I've left some high level feedback:
- The new interface is named
ICloseablebut the file isIClosable.cs; consider renaming the file (or the type) so the spelling is consistent and matches the type name. - Blocking on
Context.DisposeAsync().AsTask().Wait()inTestBase.Disposecan introduce deadlock risks; if you need synchronous disposal, preferGetAwaiter().GetResult()or making the base test typeIAsyncDisposableand disposing asynchronously in the test framework hook. - Since
ICloseableis now shared by bothModalandDialogOption, you may want to move it to a more generic/shared folder/namespace thanComponents/Modalto better reflect its cross-component usage.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new interface is named `ICloseable` but the file is `IClosable.cs`; consider renaming the file (or the type) so the spelling is consistent and matches the type name.
- Blocking on `Context.DisposeAsync().AsTask().Wait()` in `TestBase.Dispose` can introduce deadlock risks; if you need synchronous disposal, prefer `GetAwaiter().GetResult()` or making the base test type `IAsyncDisposable` and disposing asynchronously in the test framework hook.
- Since `ICloseable` is now shared by both `Modal` and `DialogOption`, you may want to move it to a more generic/shared folder/namespace than `Components/Modal` to better reflect its cross-component usage.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7644 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 750 750
Lines 33179 33182 +3
Branches 4602 4602
=========================================
+ Hits 33179 33182 +3
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:
|
There was a problem hiding this comment.
Pull request overview
Adds a shared close/closing callback contract (ICloseable) and wires dialog options into the underlying modal’s “before close” pipeline, so consumers can block close actions via OnClosingAsync.
Changes:
- Introduces
ICloseablewithOnCloseAsync/OnClosingAsynccallbacks. - Implements
ICloseableinModalandDialogOption, and passesOnClosingAsyncfromDialogtoModal. - Updates unit tests and test infrastructure (removes mock host environment registration; changes bUnit context disposal).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTest/Extensions/IServiceCollectionExtensions.cs | Removes unused mock host environment helper/types from unit test DI extensions. |
| test/UnitTest/Core/TestBase.cs | Adjusts bUnit context disposal approach after bUnit async-dispose changes; removes mock environment registration. |
| test/UnitTest/Components/DialogTest.cs | Adds a test scenario for OnClosingAsync blocking close. |
| src/BootstrapBlazor/Components/Modal/Modal.razor.cs | Makes Modal implement ICloseable and uses <inheritdoc> for callback docs. |
| src/BootstrapBlazor/Components/Modal/IClosable.cs | Adds the new ICloseable interface definition. |
| src/BootstrapBlazor/Components/Dialog/DialogOption.cs | Makes DialogOption implement ICloseable and adds OnClosingAsync. |
| src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs | Captures DialogOption.OnClosingAsync for forwarding to Modal. |
| src/BootstrapBlazor/Components/Dialog/Dialog.razor | Forwards OnClosingAsync into the nested Modal component. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Link issues
fixes #7643
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Introduce a shared closable interface and apply it to dialog-related components while adding coverage for pre-close callbacks and simplifying test infrastructure.
New Features:
Enhancements:
Tests: