Skip to content

feat(Table): add OnAfterDeleteAsync callback on DynamicContext mode#7832

Merged
ArgoZhang merged 2 commits intomainfrom
feat-table
Apr 3, 2026
Merged

feat(Table): add OnAfterDeleteAsync callback on DynamicContext mode#7832
ArgoZhang merged 2 commits intomainfrom
feat-table

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Apr 2, 2026

Link issues

fixes #7831

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Enhancements:

  • Refactor the Table component to centralize post-delete and post-modify callbacks into a shared TriggerDeleteCallback method used by all delete paths.

Copilot AI review requested due to automatic review settings April 2, 2026 05:23
@bb-auto bb-auto bot added the enhancement New feature or request label Apr 2, 2026
@bb-auto bb-auto bot added this to the v10.5.0 milestone Apr 2, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 2, 2026

Reviewer's Guide

Refactors delete callbacks in the Table component so that OnAfterDeleteAsync/OnAfterModifyAsync are centralized in a new helper and invoked consistently in DynamicContext and Excel delete flows, ensuring the after-delete callback also runs in DynamicContext mode.

Sequence diagram for delete flow with centralized callbacks

sequenceDiagram
    actor User
    participant Table
    participant DynamicContext
    participant ExcelDeleteFlow as ExcelDelete
    participant TriggerDeleteCallback
    participant OnAfterDeleteAsync
    participant OnAfterModifyAsync

    User->>Table: DeleteAsync()
    alt DynamicContext mode
        Table->>DynamicContext: DeleteAsync(SelectedRows as IDynamicObject)
        DynamicContext-->>Table: Task completed
        Table->>Table: ResetDynamicContext()
        Table->>TriggerDeleteCallback: TriggerDeleteCallback()
    else Excel mode
        Table->>ExcelDeleteFlow: InternalOnDeleteAsync()
        ExcelDeleteFlow-->>Table: Task completed
        Table->>TriggerDeleteCallback: TriggerDeleteCallback()
        Table->>Table: QueryAsync()
    else Normal mode
        User->>Table: DeleteItemsAsync()
        Table->>Table: confirm and delete items
        Table->>TriggerDeleteCallback: TriggerDeleteCallback()
        Table->>Table: SelectedRows.Clear()
        Table->>Table: QueryAsync()
    end

    TriggerDeleteCallback->>OnAfterDeleteAsync: invoke with SelectedRows
    OnAfterDeleteAsync-->>TriggerDeleteCallback: Task completed
    TriggerDeleteCallback->>OnAfterModifyAsync: invoke()
    OnAfterModifyAsync-->>TriggerDeleteCallback: Task completed
Loading

Class diagram for updated Table delete callbacks

classDiagram
    class Table
    Table : DynamicContext
    Table : bool IsExcel
    Table : List SelectedRows
    Table : Func~IEnumerable~ OnAfterDeleteAsync
    Table : Func OnAfterModifyAsync
    Table : Task DeleteAsync()
    Table : Task bool DeleteItemsAsync()
    Table : Task TriggerDeleteCallback()
    Table : void ResetDynamicContext()

    class DynamicContext
    DynamicContext : Task DeleteAsync(IEnumerable items)

    class SelectedRows
    class OnAfterDeleteAsync
    class OnAfterModifyAsync
    class TriggerDeleteCallback
    class DeleteAsync
    class DeleteItemsAsync

    Table --> DynamicContext : uses
    Table --> SelectedRows : maintains
    Table --> OnAfterDeleteAsync : invokes
    Table --> OnAfterModifyAsync : invokes
    Table --> TriggerDeleteCallback : calls
    DeleteAsync --> TriggerDeleteCallback : calls
    DeleteItemsAsync --> TriggerDeleteCallback : calls
Loading

File-Level Changes

Change Details Files
Centralize and consistently invoke after-delete callbacks for table deletions, including DynamicContext mode.
  • In DeleteAsync, invoke a new TriggerDeleteCallback helper after DynamicContext.DeleteAsync and after InternalOnDeleteAsync in the Excel path so the after-delete logic runs in both scenarios
  • In DeleteItemsAsync, replace inline OnAfterDeleteAsync/OnAfterModifyAsync invocation with a call to TriggerDeleteCallback, then clear SelectedRows and re-query
  • Introduce private TriggerDeleteCallback method to encapsulate calling OnAfterDeleteAsync with SelectedRows and OnAfterModifyAsync
src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7831 Add and invoke the OnAfterDeleteAsync callback when deleting rows in DynamicContext mode in the Table component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider renaming TriggerDeleteCallback to something like TriggerPostDeleteCallbacks or InvokeAfterDeleteAndModifyAsync to better reflect that it triggers both delete and modify callbacks, not just delete.
  • Since TriggerDeleteCallback relies on SelectedRows, it may be worth documenting that it must be called before SelectedRows.Clear() in all call sites to avoid future regressions if the order is changed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider renaming `TriggerDeleteCallback` to something like `TriggerPostDeleteCallbacks` or `InvokeAfterDeleteAndModifyAsync` to better reflect that it triggers both delete and modify callbacks, not just delete.
- Since `TriggerDeleteCallback` relies on `SelectedRows`, it may be worth documenting that it must be called before `SelectedRows.Clear()` in all call sites to avoid future regressions if the order is changed.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (8263d70) to head (9ed10d5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7832   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          764       764           
  Lines        34142     34147    +5     
  Branches      4701      4701           
=========================================
+ Hits         34142     34147    +5     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for invoking the existing post-delete callbacks (OnAfterDeleteAsync / OnAfterModifyAsync) when deleting rows in Table while using DynamicContext, aligning behavior across delete pathways.

Changes:

  • Invoke after-delete callbacks for DynamicContext and IsExcel delete flows.
  • Refactor repeated callback invocation into a shared TriggerDeleteCallback() helper.
  • Bump BootstrapBlazor package version to 10.5.1-beta01.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs Adds centralized after-delete callback triggering and wires it into DynamicContext/Excel deletion paths.
src/BootstrapBlazor/BootstrapBlazor.csproj Updates package version to a beta prerelease.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1136 to +1140
ResetDynamicContext();

// 触发删除回调方法
await TriggerDeleteCallback();

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the DynamicContext branch, ResetDynamicContext() runs before TriggerDeleteCallback(). ResetDynamicContext() ultimately calls ResetSelectedRows(QueryItems), which can replace SelectedRows with an empty list once the deleted items are no longer present. As a result, OnAfterDeleteAsync may receive the wrong (often empty) set of deleted rows. Capture SelectedRows.ToList() before resetting, and pass that snapshot into the callback (or invoke the callback before ResetDynamicContext()).

Suggested change
ResetDynamicContext();
// 触发删除回调方法
await TriggerDeleteCallback();
// 触发删除回调方法
await TriggerDeleteCallback();
ResetDynamicContext();

Copilot uses AI. Check for mistakes.
Comment on lines +1138 to +1140
// 触发删除回调方法
await TriggerDeleteCallback();

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changes behavior by firing OnAfterDeleteAsync/OnAfterModifyAsync in DynamicContext mode, but there doesn't appear to be a unit test asserting these callbacks are invoked (and with the expected deleted rows) for DynamicContext deletion. Adding a test alongside the existing DynamicContext_* Table tests would prevent regressions here.

Copilot uses AI. Check for mistakes.
Comment on lines 3 to 5
<PropertyGroup>
<Version>10.5.0</Version>
<Version>10.5.1-beta01</Version>
</PropertyGroup>
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package version is changed to 10.5.1-beta01, but the PR description doesn’t mention a versioning/release intent. If this PR isn’t meant to publish a pre-release package, consider reverting this change; otherwise, document the reason for moving to a beta version in the PR description/release process notes.

Copilot uses AI. Check for mistakes.
@ArgoZhang ArgoZhang merged commit dd73301 into main Apr 3, 2026
10 checks passed
@ArgoZhang ArgoZhang deleted the feat-table branch April 3, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Table): add OnAfterDeleteAsync callback on DynamicContext mode

2 participants