@@ -89,7 +89,7 @@ export class TableKeyboardDelegate<T> implements KeyboardDelegate {
89
89
return child . key ;
90
90
}
91
91
92
- let firstItem = this . collection . getItem ( this . collection . getFirstKey ( ) ) ;
92
+ let firstItem = this . collection . getItem ( this . getFirstKey ( ) ) ;
93
93
return [ ...firstItem . childNodes ] [ startItem . index ] . key ;
94
94
}
95
95
@@ -98,8 +98,8 @@ export class TableKeyboardDelegate<T> implements KeyboardDelegate {
98
98
key = startItem . parentKey ;
99
99
}
100
100
101
- // Find the next enabled item
102
- key = this . findNextKey ( item => item . type === 'item' && ! this . disabledKeys . has ( item . key ) , key ) ;
101
+ // Find the next item
102
+ key = this . findNextKey ( item => item . type === 'item' , key ) ;
103
103
if ( key != null ) {
104
104
// If focus was on a cell, focus the cell with the same index in the next row.
105
105
if ( this . isCell ( startItem ) ) {
@@ -133,8 +133,8 @@ export class TableKeyboardDelegate<T> implements KeyboardDelegate {
133
133
key = startItem . parentKey ;
134
134
}
135
135
136
- // Find the previous enabled item
137
- key = this . findPreviousKey ( item => item . type === 'item' && ! this . disabledKeys . has ( item . key ) , key ) ;
136
+ // Find the previous item
137
+ key = this . findPreviousKey ( item => item . type === 'item' , key ) ;
138
138
if ( key != null ) {
139
139
// If focus was on a cell, focus the cell with the same index in the previous row.
140
140
if ( this . isCell ( startItem ) ) {
@@ -282,8 +282,8 @@ export class TableKeyboardDelegate<T> implements KeyboardDelegate {
282
282
}
283
283
}
284
284
285
- // Find the first enabled row
286
- key = this . findNextKey ( item => item . type === 'item' && ! this . disabledKeys . has ( item . key ) ) ;
285
+ // Find the first row
286
+ key = this . findNextKey ( item => item . type === 'item' ) ;
287
287
288
288
// If global flag is set, focus the first cell in the first row.
289
289
if ( key != null && item && this . isCell ( item ) && global ) {
@@ -312,8 +312,8 @@ export class TableKeyboardDelegate<T> implements KeyboardDelegate {
312
312
}
313
313
}
314
314
315
- // Find the last enabled row
316
- key = this . findPreviousKey ( item => item . type === 'item' && ! this . disabledKeys . has ( item . key ) ) ;
315
+ // Find the last row
316
+ key = this . findPreviousKey ( item => item . type === 'item' ) ;
317
317
318
318
// If global flag is set, focus the last cell in the last row.
319
319
if ( key != null && item && this . isCell ( item ) && global ) {
@@ -375,16 +375,23 @@ export class TableKeyboardDelegate<T> implements KeyboardDelegate {
375
375
376
376
getKeyPageBelow ( key : Key ) {
377
377
let itemRect = this . getItemRect ( key ) ;
378
+
378
379
if ( ! itemRect ) {
379
380
return null ;
380
381
}
381
382
382
383
let pageHeight = this . getPageHeight ( ) ;
383
- let pageY = Math . min ( this . getContentHeight ( ) - pageHeight , itemRect . y + pageHeight ) ;
384
+ let pageY = Math . min ( this . getContentHeight ( ) , itemRect . y + pageHeight ) ;
384
385
385
386
while ( itemRect && itemRect . maxY < pageY ) {
386
- key = this . getKeyBelow ( key ) ;
387
- itemRect = this . getItemRect ( key ) ;
387
+ let nextKey = this . getKeyBelow ( key ) ;
388
+ itemRect = this . getItemRect ( nextKey ) ;
389
+
390
+ // Guard against case where maxY of the last key is barely less than pageY due to rounding
391
+ // and thus it attempts to set key to null
392
+ if ( nextKey != null ) {
393
+ key = nextKey ;
394
+ }
388
395
}
389
396
390
397
return key ;
0 commit comments