Thanks to visit codestin.com
Credit goes to github.com

Skip to content

updateRows() Issue #2277

@bjcasillas89

Description

@bjcasillas89

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @swimlane/[email protected] for the project I'm working on.

In production build of my application, I keep having thousands of error log messages generated from the updateRows() function. Looking at the version of ngx-datatable we were using compared to the latest, I saw there were significant changes done to this function, specifically the updates to using signals. This is causing a lot of issues because rows.length now may produce a negative number. I implemented a guard to protect against this and I'm using patch-package for now until this becomes an official fix.

Here is the diff that solved my problem:

diff --git a/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs b/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs
index 5776af9..05620af 100644
--- a/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs
+++ b/node_modules/@swimlane/ngx-datatable/fesm2022/swimlane-ngx-datatable.mjs
@@ -2419,7 +2419,7 @@ class DataTableBodyComponent {
         const rows = this.groupedRows
             ? this.groupedRows.slice(first, Math.min(last, this.groupedRows.length))
             : this.rows.slice(first, Math.min(last, this.rowCount));
-        rows.length = last - first;
+        rows.length = Math.max(0, last - first);
         return rows;
     }
     /**

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions