Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 412073d

Browse files
committed
Merge pull request #142 from jaredly/fix-search-results
Fix search results
2 parents 5cc7547 + a5d4ae0 commit 412073d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

frontend/Store.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class Store extends EventEmitter {
180180
});
181181
} else {
182182
this.searchRoots = this._nodes.entrySeq()
183-
.filter(([key, val]) => nodeMatchesText(val, needle))
183+
.filter(([key, val]) => nodeMatchesText(val, needle, key, this))
184184
.map(([key, val]) => key)
185185
.toList();
186186
}
@@ -347,7 +347,7 @@ class Store extends EventEmitter {
347347
if (nodeType !== 'Wrapper' && nodeType !== 'Native') {
348348
return id;
349349
}
350-
if (nodeType === 'Native' && this.get(this._parents.get(id)).get('nodeType') !== 'NativeWrapper') {
350+
if (nodeType === 'Native' && (!up || this.get(this._parents.get(id)).get('nodeType') !== 'NativeWrapper')) {
351351
return id;
352352
}
353353
if (up) {
@@ -427,7 +427,7 @@ class Store extends EventEmitter {
427427
var curNodes = this._nodesByName.get(data.name) || new Set();
428428
this._nodesByName = this._nodesByName.set(data.name, curNodes.add(data.id));
429429
this.emit(data.id);
430-
if (this.searchRoots && nodeMatchesText(map, this.searchText.toLowerCase())) {
430+
if (this.searchRoots && nodeMatchesText(map, this.searchText.toLowerCase(), data.id, this)) {
431431
this.searchRoots = this.searchRoots.push(data.id);
432432
this.emit('searchRoots');
433433
}

frontend/nodeMatchesText.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
'use strict';
1212

1313
import type {Map} from 'immutable';
14+
import type Store from './Store';
1415

15-
function nodeMatchesText(node: Map, needle: string): boolean {
16+
function nodeMatchesText(node: Map, needle: string, key: string, store: Store): boolean {
1617
var name = node.get('name');
18+
if (node.get('nodeType') === 'Native' && store.get(store.getParent(key)).get('nodeType') === 'NativeWrapper') {
19+
return false;
20+
}
1721
if (name) {
1822
if (node.get('nodeType') !== 'Wrapper' && name.toLowerCase().indexOf(needle) !== -1) {
1923
return true;

0 commit comments

Comments
 (0)