Merge pull request #62 from gaearon/search-fix

Move selection when typing in search field
This commit is contained in:
Brian Vaughn
2019-04-04 08:14:57 -07:00
committed by GitHub
+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;