Skip to content

Commit 150757d

Browse files
authored
fix: make sure Row Detail item exists before trying to access it (#2026)
* fix: make sure Row Detail item exists before trying to access it This Pull Request adds a check to ensure item exists before trying to access a property in it.
1 parent 23d94b3 commit 150757d

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

packages/row-detail-view-plugin/src/slickRowDetailView.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -784,22 +784,25 @@ export class SlickRowDetailView implements ExternalResource, UniversalRowDetailV
784784

785785
protected handleRemoveRow(rowIndex: number): void {
786786
const item = this.dataView.getItemByIdx(rowIndex);
787-
const rowId = item[this.dataViewIdProperty];
788787

789-
if (this._expandedRowIds.has(rowId)) {
790-
this.onBeforeRowOutOfViewportRange.notify(
791-
{
792-
grid: this._grid,
793-
item,
794-
rowId,
795-
rowIndex,
796-
expandedRows: Array.from(this._expandedRowIds).map((id) => this.dataView.getItemById(id)),
797-
rowIdsOutOfViewport: Array.from(this.syncOutOfViewportArray(rowId, true)),
798-
},
799-
null,
800-
this
801-
);
802-
this._disposedRows.add(rowIndex);
788+
if (item) {
789+
const rowId = item[this.dataViewIdProperty];
790+
791+
if (this._expandedRowIds.has(rowId)) {
792+
this.onBeforeRowOutOfViewportRange.notify(
793+
{
794+
grid: this._grid,
795+
item,
796+
rowId,
797+
rowIndex,
798+
expandedRows: Array.from(this._expandedRowIds).map((id) => this.dataView.getItemById(id)),
799+
rowIdsOutOfViewport: Array.from(this.syncOutOfViewportArray(rowId, true)),
800+
},
801+
null,
802+
this
803+
);
804+
this._disposedRows.add(rowIndex);
805+
}
803806
}
804807
}
805808

0 commit comments

Comments
 (0)