Skip to content

Commit 14969c2

Browse files
authored
Merge pull request facebook#62 from gaearon/search-fix
Move selection when typing in search field
2 parents 7fbdfd9 + ec71171 commit 14969c2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/devtools/views/Components/TreeContext.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
195195
} = state;
196196

197197
const prevSearchIndex = searchIndex;
198+
const prevSearchText = searchText;
198199
const numPrevSearchResults = searchResults.length;
199200

200201
// Search isn't supported when the owner's tree is active.
@@ -307,8 +308,8 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
307308
}
308309
}
309310

310-
// Changes in search index should override the selected element.
311-
if (searchIndex !== prevSearchIndex) {
311+
// Changes in search index or typing should override the selected element.
312+
if (searchIndex !== prevSearchIndex || searchText.indexOf(prevSearchText) === 0) {
312313
if (searchIndex === null) {
313314
selectedElementIndex = null;
314315
selectedElementID = null;

0 commit comments

Comments
 (0)