Skip to content

fix: use numeric sort in deleteItems to prevent data loss#2574

Merged
ghiscoding merged 2 commits intomasterfrom
bugfix/dataview-sort-indexes
May 8, 2026
Merged

fix: use numeric sort in deleteItems to prevent data loss#2574
ghiscoding merged 2 commits intomasterfrom
bugfix/dataview-sort-indexes

Conversation

@ghiscoding
Copy link
Copy Markdown
Owner

@ghiscoding ghiscoding commented May 7, 2026

fixes an old issue opened in SlickGrid (6pac) project: 6pac/SlickGrid#1178

vibe coded a fix with Copilot

Description

Fixes incorrect array sorting in deleteItems() method that could cause data loss when deleting multiple items.

Problem

The indexesToDelete array was sorted without a comparator using sort(), which defaults to lexicographic (string) ordering instead of numeric ordering. This caused incorrect item deletion when array indices contained multi-digit numbers.

Example:

  • Indices: [10, 2, 3, 20]
  • Without comparator: ['10', '2', '20', '3'] → incorrect order
  • With comparator: [2, 3, 10, 20] → correct numeric order

Since items are deleted from back to front based on these indices, incorrect ordering resulted in wrong items being removed from the dataset.

Solution

Added numeric comparator to sort() call: sort((a, b) => a - b)

Files Changed

  • packages/common/src/core/slickDataview.ts - Fixed deleteItems() method

Testing

Existing unit tests cover this functionality and should pass with the fix applied.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

angular-slickgrid

npm i https://pkg.pr.new/angular-slickgrid@2574

aurelia-slickgrid

npm i https://pkg.pr.new/aurelia-slickgrid@2574

slickgrid-react

npm i https://pkg.pr.new/slickgrid-react@2574

slickgrid-vue

npm i https://pkg.pr.new/slickgrid-vue@2574

@slickgrid-universal/angular-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/angular-row-detail-plugin@2574

@slickgrid-universal/aurelia-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/aurelia-row-detail-plugin@2574

@slickgrid-universal/react-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/react-row-detail-plugin@2574

@slickgrid-universal/vue-row-detail-plugin

npm i https://pkg.pr.new/@slickgrid-universal/vue-row-detail-plugin@2574

@slickgrid-universal/binding

npm i https://pkg.pr.new/@slickgrid-universal/binding@2574

@slickgrid-universal/common

npm i https://pkg.pr.new/@slickgrid-universal/common@2574

@slickgrid-universal/composite-editor-component

npm i https://pkg.pr.new/@slickgrid-universal/composite-editor-component@2574

@slickgrid-universal/custom-footer-component

npm i https://pkg.pr.new/@slickgrid-universal/custom-footer-component@2574

@slickgrid-universal/custom-tooltip-plugin

npm i https://pkg.pr.new/@slickgrid-universal/custom-tooltip-plugin@2574

@slickgrid-universal/empty-warning-component

npm i https://pkg.pr.new/@slickgrid-universal/empty-warning-component@2574

@slickgrid-universal/event-pub-sub

npm i https://pkg.pr.new/@slickgrid-universal/event-pub-sub@2574

@slickgrid-universal/excel-export

npm i https://pkg.pr.new/@slickgrid-universal/excel-export@2574

@slickgrid-universal/graphql

npm i https://pkg.pr.new/@slickgrid-universal/graphql@2574

@slickgrid-universal/odata

npm i https://pkg.pr.new/@slickgrid-universal/odata@2574

@slickgrid-universal/pagination-component

npm i https://pkg.pr.new/@slickgrid-universal/pagination-component@2574

@slickgrid-universal/pdf-export

npm i https://pkg.pr.new/@slickgrid-universal/pdf-export@2574

@slickgrid-universal/row-detail-view-plugin

npm i https://pkg.pr.new/@slickgrid-universal/row-detail-view-plugin@2574

@slickgrid-universal/rxjs-observable

npm i https://pkg.pr.new/@slickgrid-universal/rxjs-observable@2574

@slickgrid-universal/sql

npm i https://pkg.pr.new/@slickgrid-universal/sql@2574

@slickgrid-universal/text-export

npm i https://pkg.pr.new/@slickgrid-universal/text-export@2574

@slickgrid-universal/utils

npm i https://pkg.pr.new/@slickgrid-universal/utils@2574

@slickgrid-universal/vanilla-bundle

npm i https://pkg.pr.new/@slickgrid-universal/vanilla-bundle@2574

@slickgrid-universal/vanilla-force-bundle

npm i https://pkg.pr.new/@slickgrid-universal/vanilla-force-bundle@2574

commit: b31d6b1

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (15e3ca0) to head (b31d6b1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2574   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         196      196           
  Lines       25275    25275           
  Branches     8925     8925           
=======================================
  Hits        25275    25275           
Flag Coverage Δ
angular 100.0% <ø> (ø)
universal 100.0% <100.0%> (ø)

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.

@ghiscoding ghiscoding merged commit f96f598 into master May 8, 2026
14 checks passed
@ghiscoding ghiscoding deleted the bugfix/dataview-sort-indexes branch May 8, 2026 13:37
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

🎉 This pull request is included in version 10.7.0 📦
🔗 The release notes are available at: GitHub Release 🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant