Skip to content

fix(SorableList): generate two client item when use clone mode#630

Merged
ArgoZhang merged 2 commits intomasterfrom
fix-sortable
Oct 24, 2025
Merged

fix(SorableList): generate two client item when use clone mode#630
ArgoZhang merged 2 commits intomasterfrom
fix-sortable

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Oct 24, 2025

Link issues

fixes #629

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

Make the onAdd handler asynchronous and remove extra cloned items when using clone mode to prevent duplicate list entries.

Bug Fixes:

  • Prevent generating duplicate items in SortableList when using clone mode by removing the extra clone after add.

Enhancements:

  • Convert the onAdd callback to async and await the TriggerAdd invocation.

Copilot AI review requested due to automatic review settings October 24, 2025 15:11
@bb-auto bb-auto Bot added the bug Something isn't working label Oct 24, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Oct 24, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Oct 24, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the SortableList JavaScript handler by making the onAdd event async (awaiting the .NET call) and removing the extra cloned item when using clone pullMode.

Sequence diagram for async onAdd event and clone item removal in SortableList

sequenceDiagram
participant JS as "SortableList.razor.js"
participant DotNet as ".NET Invoke Handler"
JS->>DotNet: invokeMethodAsync('TriggerAdd', items)
Note over JS,DotNet: Await .NET method completion
alt event.pullMode == 'clone'
    JS->>JS: event.item.remove()
end
Loading

File-Level Changes

Change Details Files
Refactor onAdd callback to be asynchronous and await the TriggerAdd invocation
  • Changed op.onAdd handler signature to async
  • Awaited invoke.invokeMethodAsync('TriggerAdd', items)
src/components/BootstrapBlazor.Sortable/Components/SortableList.razor.js
Prevent duplicate items in clone mode by removing the automatically added clone
  • Added a check for event.pullMode === 'clone'
  • Removed the cloned DOM element via event.item.remove()
src/components/BootstrapBlazor.Sortable/Components/SortableList.razor.js

Assessment against linked issues

Issue Objective Addressed Explanation
#629 Fix the bug where two client items are generated when using clone mode in SortableList.
#629 Ensure that only one client item is kept when using clone mode in SortableList.

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

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

This PR fixes an issue where sortable list items were being duplicated when using clone mode. The fix ensures that when an item is cloned and added to a new list, the cloned DOM element is properly removed after the server-side state is updated.

Key Changes:

  • Modified the onAdd event handler to be asynchronous and wait for the server-side TriggerAdd method to complete
  • Added logic to remove the cloned DOM element after successful server-side processing when in clone mode
  • Updated version number and package references to support both Visual Studio 17.0 and 18.0

Reviewed Changes

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

File Description
SortableList.razor.js Fixed clone mode duplicate item issue by making onAdd async and removing cloned elements after server processing
BootstrapBlazor.Sortable.csproj Added conditional version configuration for different Visual Studio versions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Copy Markdown

@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 there - I've reviewed your changes and they look great!


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.

@ArgoZhang ArgoZhang merged commit 8a68e03 into master Oct 24, 2025
2 checks passed
@ArgoZhang ArgoZhang deleted the fix-sortable branch October 24, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(SorableList): generate two client item when use clone mode

2 participants