Reverted some unnecessary changes to TreeContext after Dan's PR 101 was merged
Brian Vaughn committed
Apr 10, 2019 at 07:45 UTC
b004a794152df4051e02661c04dcd718f7b60c7e
1 file changed
+5
-20
src/devtools/views/Components/TreeContext.js
+5
-20
@@ -199,7 +199,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
199
selectedElementIndex,
200
} = state;
201
202
- let prevSearchIndex = searchIndex;
202
+ const prevSearchIndex = searchIndex;
203
const prevSearchText = searchText;
204
const numPrevSearchResults = searchResults.length;
205
@@ -307,25 +307,10 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
307
if (prevSearchIndex === null) {
308
searchIndex = 0;
309
} else {
310
- // Changes in search index or typing should override the selected element.
311
- // The one exception is when a search is broadened (e.g. "Cat" -> "Ca").
312
- // In this case, it's probably desirable to maintain a stable selection.
313
- // Replacements of text( e.g. "cat" -> "dog") likely require an index change.
314
- const didRelaxSearchText =
315
- prevSearchText.length > searchText.length &&
316
- prevSearchText.startsWith(searchText);
317
- if (didRelaxSearchText) {
318
- searchIndex = prevSearchIndex;
319
- } else {
320
- searchIndex = Math.min(
321
- ((prevSearchIndex: any): number),
322
- searchResults.length - 1
323
- );
324
-
325
- // Force selected element ID to be re-evaluated below, even if the search index didn't change,
326
- // because new search text means the same index may now point to a new element.
327
- prevSearchIndex = null;
328
- }
310
+ searchIndex = Math.min(
311
+ ((prevSearchIndex: any): number),
312
+ searchResults.length - 1
313
+ );
314
}
315
}
316
}