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

Commit 16508e2

Browse files
committed
fix search result listing to exclude native wrapped components
1 parent 4ed698a commit 16508e2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

frontend/Store.js

Lines changed: 8 additions & 4 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,13 +347,17 @@ 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) {
354354
return this._parents.get(id);
355355
}
356-
return node.get('children')[0];
356+
var children = node.get('children');
357+
if ('string' === typeof children) {
358+
return children;
359+
}
360+
return children[0];
357361
}
358362

359363
off(evt: string, fn: ListenerFunction): void {
@@ -427,7 +431,7 @@ class Store extends EventEmitter {
427431
var curNodes = this._nodesByName.get(data.name) || new Set();
428432
this._nodesByName = this._nodesByName.set(data.name, curNodes.add(data.id));
429433
this.emit(data.id);
430-
if (this.searchRoots && nodeMatchesText(map, this.searchText.toLowerCase())) {
434+
if (this.searchRoots && nodeMatchesText(map, this.searchText.toLowerCase(), data.id, this)) {
431435
this.searchRoots = this.searchRoots.push(data.id);
432436
this.emit('searchRoots');
433437
}

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)