mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Move selection when typing in search field
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user