@@ -7,7 +7,11 @@ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement
77import property from "@ui5/webcomponents-base/dist/decorators/property.js" ;
88import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js" ;
99import TableSelectionMode from "./types/TableSelectionMode.js" ;
10- import { isSelectionCell , isHeaderSelectionCell , findRowInPath } from "./TableUtils.js" ;
10+ import {
11+ isSelectionCell ,
12+ isHeaderSelectionCell ,
13+ findRowInPath ,
14+ } from "./TableUtils.js" ;
1115import type Table from "./Table.js" ;
1216import type { ITableFeature } from "./Table.js" ;
1317import type TableRow from "./TableRow.js" ;
@@ -143,8 +147,8 @@ class TableSelection extends UI5Element implements ITableFeature {
143147 return undefined ;
144148 }
145149
146- getRowKey ( row : TableRow ) : string {
147- return row . rowKey || "" ;
150+ getRowKey ( row : TableRowBase ) : string {
151+ return "rowKey" in row ? ( row . rowKey as string ) || "" : "" ;
148152 }
149153
150154 isSelected ( row : TableRowBase ) : boolean {
@@ -166,7 +170,7 @@ class TableSelection extends UI5Element implements ITableFeature {
166170 }
167171
168172 const selectedArray = this . selectedAsArray ;
169- return this . _table . rows . some ( row => {
173+ return this . _table . _rows . some ( row => {
170174 const rowKey = this . getRowKey ( row ) ;
171175 return selectedArray . includes ( rowKey ) ;
172176 } ) ;
@@ -178,7 +182,7 @@ class TableSelection extends UI5Element implements ITableFeature {
178182 }
179183
180184 const selectedArray = this . selectedAsArray ;
181- return this . _table . rows . every ( row => {
185+ return this . _table . _rows . every ( row => {
182186 const rowKey = this . getRowKey ( row ) ;
183187 return selectedArray . includes ( rowKey ) ;
184188 } ) ;
@@ -229,7 +233,7 @@ class TableSelection extends UI5Element implements ITableFeature {
229233
230234 _selectHeaderRow ( selected : boolean ) {
231235 const selectedSet = this . selectedAsSet ;
232- this . _table ! . rows . forEach ( row => {
236+ this . _table ! . _rows . forEach ( row => {
233237 const rowKey = this . getRowKey ( row ) ;
234238 selectedSet [ selected ? "add" : "delete" ] ( rowKey ) ;
235239 } ) ;
@@ -312,8 +316,8 @@ class TableSelection extends UI5Element implements ITableFeature {
312316
313317 if ( e . shiftKey && this . _rangeSelection ?. isMouse ) {
314318 const startRow = this . _rangeSelection . rows [ 0 ] ;
315- const startIndex = this . _table . rows . indexOf ( startRow ) ;
316- const endIndex = this . _table . rows . indexOf ( row ) ;
319+ const startIndex = this . _table . _rows . indexOf ( startRow ) ;
320+ const endIndex = this . _table . _rows . indexOf ( row ) ;
317321
318322 const selectionState = this . isSelected ( startRow ) ;
319323
@@ -369,10 +373,11 @@ class TableSelection extends UI5Element implements ITableFeature {
369373 if ( shouldReverseSelection ) {
370374 this . _reverseRangeSelection ( ) ;
371375 } else {
372- const rowIndex = this . _table ! . rows . indexOf ( targetRow ) ;
376+ const rows = this . _table ! . _rows ;
377+ const rowIndex = rows . indexOf ( targetRow ) ;
373378 const [ startIndex , endIndex ] = [ rowIndex , rowIndex - change ] . sort ( ( a , b ) => a - b ) ;
374379
375- selectionChanged = this . _table ?. rows . slice ( startIndex , endIndex + 1 ) . reduce ( ( changed , row ) => {
380+ selectionChanged = rows . slice ( startIndex , endIndex + 1 ) . reduce ( ( changed , row ) => {
376381 const isRowNotInSelection = ! this . _rangeSelection ?. rows . includes ( row ) ;
377382 const isRowSelectionDifferent = this . isSelected ( row ) !== this . _rangeSelection ! . selected ;
378383
0 commit comments