@@ -386,13 +386,22 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
386
386
}
387
387
// TODO (inline errors) The element indices are incorrect if the element is hidden in a collapsed tree.
388
388
// Shouldn't hidden elements excluded from computing a valid index?
389
- const elementIndicesWithErrorsOrWarnings = Array . from (
389
+ const elementIndicesWithErrorsOrWarnings : number [ ] = Array . from (
390
390
store . errorsAndWarnings . keys ( ) ,
391
- elementId => store . getIndexOfElementID ( elementId ) ,
392
- ) ;
391
+ )
392
+ . map ( elementId => {
393
+ // $FlowFixMe https://github.com/facebook/flow/issues/1414
394
+ return store . getIndexOfElementID ( elementId ) ;
395
+ } )
396
+ . filter ( elementIndex => {
397
+ return elementIndex !== null ;
398
+ } ) ;
393
399
const predecessors = elementIndicesWithErrorsOrWarnings . filter (
394
400
elementIndex => {
395
- return elementIndex !== null && elementIndex < selectedElementIndex ;
401
+ return (
402
+ selectedElementIndex === null ||
403
+ elementIndex < selectedElementIndex
404
+ ) ;
396
405
} ,
397
406
) ;
398
407
if ( predecessors . length === 0 ) {
@@ -409,13 +418,22 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
409
418
return state ;
410
419
}
411
420
412
- const elementIndicesWithErrorsOrWarnings = Array . from (
421
+ const elementIndicesWithErrorsOrWarnings : number [ ] = Array . from (
413
422
store . errorsAndWarnings . keys ( ) ,
414
- elementId => store . getIndexOfElementID ( elementId ) ,
415
- ) ;
423
+ )
424
+ . map ( elementId => {
425
+ // $FlowFixMe https://github.com/facebook/flow/issues/1414
426
+ return store . getIndexOfElementID ( elementId ) ;
427
+ } )
428
+ . filter ( elementIndex => {
429
+ return elementIndex !== null ;
430
+ } ) ;
416
431
const successors = elementIndicesWithErrorsOrWarnings . filter (
417
432
elementIndex => {
418
- return elementIndex !== null && elementIndex > selectedElementIndex ;
433
+ return (
434
+ selectedElementIndex === null ||
435
+ elementIndex > selectedElementIndex
436
+ ) ;
419
437
} ,
420
438
) ;
421
439
if ( successors . length === 0 ) {
0 commit comments