Skip to content

Commit 6c112b2

Browse files
committed
Search fixes
* When searching, don't link to routes that dont exist (was throwing glimmer error) * Don't load search index until didInsertElement, fix for addons that support fastboot
1 parent a50cadb commit 6c112b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

addon/components/docs-viewer/x-search/component.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export default Component.extend(EKMixin, {
1616
query: null,
1717
selectedIndex: null,
1818

19-
init() {
19+
didInsertElement() {
2020
this._super();
2121

2222
this.set('keyboardActivated', true);
23+
2324
// Start downloading the search index immediately
2425
this.get('docsSearch').loadSearchIndex();
2526
},
@@ -45,11 +46,14 @@ export default Component.extend(EKMixin, {
4546

4647
searchResults: computed('rawSearchResults.[]', function() {
4748
let rawSearchResults = this.get('rawSearchResults');
49+
let router = this.get('router');
50+
let routerMicrolib = router._router._routerMicrolib || router._router.router;
4851

4952
if (rawSearchResults) {
5053
let filteredSearchResults = this.get('rawSearchResults')
5154
.filter(({ document }) => {
52-
return document.route !== 'not-found';
55+
let routeExists = routerMicrolib.recognizer.names[document.route];
56+
return routeExists && document.route !== 'not-found';
5357
})
5458
.filter(({ document }) => {
5559
let isClassTemplate = (document.route === 'docs.api.class' && document.type === 'template');

0 commit comments

Comments
 (0)