Skip to content

Enable multiDrag only when a selection class is configured - #16

Open
Kebechet wants to merge 1 commit into
AlexNek:mainfrom
Kebechet:fix/multidrag-always-enabled
Open

Enable multiDrag only when a selection class is configured#16
Kebechet wants to merge 1 commit into
AlexNek:mainfrom
Kebechet:fix/multidrag-always-enabled

Conversation

@Kebechet

Copy link
Copy Markdown

Problem

let multiDrag = (typeof cssForSelection !== 'undefined');

_cssForSelection is an uninitialised string field and is only assigned when settings.MultiSelection is set. .NET marshals an unset string as JSON null, never undefined, and typeof null === 'object' — so this expression is always true. Every list is constructed with multiDrag: true and selectedClass: null, whether or not multi-selection was requested.

The Array.from(event.newIndicies) calls in onUpdate/onRemove currently only survive because of this: oldIndicies/newIndicies are added exclusively by the MultiDrag plugin's eventProperties(), so with multiDrag correctly off they are undefined and Array.from would throw.

Implementation

  • multiDrag is now a truthiness check on cssForSelection, so null and '' both correctly disable it.
  • selectedClass passes undefined instead of null when unset, so SortableJS applies its own default rather than a null class.
  • newIndicies is guarded in both onUpdate and onRemove, falling back to [] — required now that multiDrag can actually be off.

Copilot AI review requested due to automatic review settings July 25, 2026 17:31
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Kebechet, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d447bf15-eb56-47f0-9871-91ff42061366

📥 Commits

Reviewing files that changed from the base of the PR and between 6b2c5ba and f8d1e08.

📒 Files selected for processing (1)
  • BlazorSortableList.Lib/SortableList.razor.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

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 multi-selection configuration for the SortableJS integration by ensuring MultiDrag is only enabled when a selection CSS class is actually configured, and by hardening event handling for cases where MultiDrag-specific event properties are absent.

Changes:

  • Compute multiDrag via a truthiness check on cssForSelection (so null/'' correctly disable MultiDrag).
  • Pass undefined (not null) for selectedClass when no selection class is configured.
  • Guard event.newIndicies usage in onUpdate/onRemove to avoid Array.from(undefined) when MultiDrag is off.
Comments suppressed due to low confidence (1)

BlazorSortableList.Lib/SortableList.razor.js:129

  • Same issue as onUpdate: if MultiDrag is off, oldDraggableIndex/newDraggableIndex may be missing and JS interop will attempt to pass undefined into OnRemoveJS(int, int, ...). Falling back to oldIndex/newIndex makes the handler robust across Sortable configurations/versions.
            let oldIndex = event.oldDraggableIndex;
            let newIndex = event.newDraggableIndex;

            // in multi selection mode we have newIndicies only
            // Only the MultiDrag plugin adds these, so they are undefined when multiDrag is off.

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

Comment on lines 79 to +83
let oldIndex = event.oldDraggableIndex;
let newIndex = event.newDraggableIndex;
// in multi selection mode we have newIndicies only
let newIndicies = Array.from(event.newIndicies);
// Only the MultiDrag plugin adds these, so they are undefined when multiDrag is off.
let newIndicies = event.newIndicies ? Array.from(event.newIndicies) : [];

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I do not think this one holds. oldDraggableIndex/newDraggableIndex are core SortableJS state, not MultiDrag additions - they are module-level variables in src/Sortable.js, assigned in _prepareDragStart, _onDragOver and _onDrop, and included in every dispatched event regardless of which plugins are mounted.

The genuinely MultiDrag-only properties are oldIndicies/newIndicies, which come from the plugin's eventProperties() - and those are exactly what this PR guards. Leaving the draggable indices as they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants