diff --git a/src/devtools/views/Elements/TreeContext.js b/src/devtools/views/Elements/TreeContext.js index 616f6409..d6dba99d 100644 --- a/src/devtools/views/Elements/TreeContext.js +++ b/src/devtools/views/Elements/TreeContext.js @@ -195,9 +195,11 @@ function reduceSearchState(store: Store, state: State, action: Action): State { } = state; const prevSearchIndex = searchIndex; + console.log('searchIndex: ', searchIndex); const numPrevSearchResults = searchResults.length; // Search isn't supported when the owner's tree is active. + console.log('type: ', type); if (ownerStack.length === 0) { switch (type) { case 'GO_TO_NEXT_SEARCH_RESULT': @@ -288,7 +290,6 @@ function reduceSearchState(store: Store, state: State, action: Action): State { store.roots.forEach(rootID => { recursivelySearchTree(store, rootID, regExp, searchResults); }); - if (searchResults.length > 0) { if (prevSearchIndex === null) { searchIndex = 0; @@ -308,7 +309,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State { } // Changes in search index should override the selected element. - if (searchIndex !== prevSearchIndex) { + if (searchIndex !== prevSearchIndex || prevSearchIndex === 0) { if (searchIndex === null) { selectedElementIndex = null; selectedElementID = null;