Skip to content

Commit

Permalink
Fixed possible undefined error in TreeContext reducer (#24501)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn authored May 5, 2022
1 parent 024a727 commit d4acbe8
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,11 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
}
break;
case 'SELECT_PREVIOUS_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE': {
if (store.errorCount === 0 && store.warningCount === 0) {
const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();
if (elementIndicesWithErrorsOrWarnings.length === 0) {
return state;
}

const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();

let flatIndex = 0;
if (selectedElementIndex !== null) {
// Resume from the current position in the list.
Expand Down Expand Up @@ -419,12 +418,11 @@ function reduceTreeState(store: Store, state: State, action: Action): State {
break;
}
case 'SELECT_NEXT_ELEMENT_WITH_ERROR_OR_WARNING_IN_TREE': {
if (store.errorCount === 0 && store.warningCount === 0) {
const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();
if (elementIndicesWithErrorsOrWarnings.length === 0) {
return state;
}

const elementIndicesWithErrorsOrWarnings = store.getElementsWithErrorsAndWarnings();

let flatIndex = -1;
if (selectedElementIndex !== null) {
// Resume from the current position in the list.
Expand Down

0 comments on commit d4acbe8

Please sign in to comment.