-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(Console): update OnClear support async #6325
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 GuideThis PR enhances the Console component’s Clear API to support asynchronous handlers by switching the OnClear callback from Action to Func, refactors the internal ClearConsole method, updates the Razor markup, and adapts both unit tests and a sample component for async usage. Sequence diagram for async OnClear invocation in Console componentsequenceDiagram
participant User as actor User
participant Console as Console component
participant App as Application logic (OnClear handler)
User->>Console: Click Clear button
Console->>App: await OnClear()
App-->>Console: Task completed
Console-->>User: UI updated
Class diagram for updated Console component async OnClear supportclassDiagram
class Console {
+Func<Task>? OnClear
-bool ShowFooter
+Task OnClearConsole()
}
class Consoles {
-Task OnClear()
}
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.
Pull Request Overview
This PR enables asynchronous clear callbacks in the Console component by converting the OnClear delegate from Action to Func<Task> and updating related logic, markup, tests, and samples.
- Change
OnClearparameter toFunc<Task>and introduceOnClearConsoleasync method - Update Razor markup to invoke
OnClearConsoleon button click - Refactor unit tests and sample usage to use async Task delegates
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/UnitTest/Components/ConsoleTest.cs | Updated tests to async Task methods and use Func<Task> for OnClear callbacks |
| src/BootstrapBlazor/Components/Console/Console.razor.cs | Switched OnClear to Func<Task>, made ShowFooter private, and implemented OnClearConsole async |
| src/BootstrapBlazor/Components/Console/Console.razor | Updated <Button> markup to call OnClearConsole instead of ClearConsole |
| src/BootstrapBlazor.Server/Components/Samples/Consoles.razor.cs | Changed sample OnClear handler to return Task |
Comments suppressed due to low confidence (2)
src/BootstrapBlazor/Components/Console/Console.razor.cs:197
- [nitpick] Consider renaming
OnClearConsoletoClearConsoleAsync(orClearAsync) to follow common async naming conventions and improve clarity.
public async Task OnClearConsole()
src/BootstrapBlazor/Components/Console/Console.razor.cs:124
- [nitpick] Update the XML doc comment above
OnClearto note that it is now an asyncFunc<Task>and will be awaited by the component.
public Func<Task>? OnClear { get; set; }
| { | ||
| <Button Text="@ClearButtonText" Icon="@ClearButtonIcon" Color="@ClearButtonColor" OnClick="ClearConsole" class="console-clear" /> | ||
| <Button Text="@ClearButtonText" Icon="@ClearButtonIcon" Color="@ClearButtonColor" | ||
| OnClick="OnClearConsole" class="console-clear"></Button> |
Copilot
AI
Jun 28, 2025
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.
[nitpick] For consistency with the rest of the component markup, consider using a self-closing <Button ... /> tag instead of an explicit closing </Button>.
| OnClick="OnClearConsole" class="console-clear"></Button> | |
| OnClick="OnClearConsole" class="console-clear" /> |
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!
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 #6325 +/- ##
=======================================
Coverage 99.98% 99.98%
=======================================
Files 715 715
Lines 31516 31519 +3
Branches 4447 4447
=======================================
+ Hits 31512 31515 +3
Misses 3 3
Partials 1 1
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 #6324
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enable asynchronous clear callbacks in the Console component by switching OnClear to Func, updating the component logic, markup, unit tests, and sample usage accordingly
Enhancements:
Tests:
Chores: