@samitouri / QOS-React / commits / ec71171bec

Move selection when typing in search field

Dan Abramov committed Apr 4, 2019 at 15:59 UTC ec71171becee3d5949229661e47c3bdbd565fc7f
1 file changed +3 -2
src/devtools/views/Components/TreeContext.js
+3 -2
@@ -195,6 +195,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
195 } = state;
196
197 const prevSearchIndex = searchIndex;
198 + const prevSearchText = searchText;
199 const numPrevSearchResults = searchResults.length;
200
201 // Search isn't supported when the owner's tree is active.
@@ -307,8 +308,8 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
308 }
309 }
310
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) {
313 if (searchIndex === null) {
314 selectedElementIndex = null;
315 selectedElementID = null;