Move selection when typing in search field

This commit is contained in:
Dan Abramov
2019-04-04 15:59:06 +01:00
parent 7fbdfd9f5a
commit ec71171bec
+3 -2
View File
@@ -195,6 +195,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
} = state;
const prevSearchIndex = searchIndex;
const prevSearchText = searchText;
const numPrevSearchResults = searchResults.length;
// Search isn't supported when the owner's tree is active.
@@ -307,8 +308,8 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
}
}
// Changes in search index should override the selected element.
if (searchIndex !== prevSearchIndex) {
// Changes in search index or typing should override the selected element.
if (searchIndex !== prevSearchIndex || searchText.indexOf(prevSearchText) === 0) {
if (searchIndex === null) {
selectedElementIndex = null;
selectedElementID = null;