diff --git a/js/src/forum/ForumApplication.js b/js/src/forum/ForumApplication.js index 34d685843..2e52abb1d 100644 --- a/js/src/forum/ForumApplication.js +++ b/js/src/forum/ForumApplication.js @@ -37,7 +37,7 @@ export default class ForumApplication extends Application { /** * The page's search component instance. * - * @type {SearchBox} + * @type {Search} */ search = new Search(); diff --git a/js/src/forum/components/Search.js b/js/src/forum/components/Search.js index 896c50e48..ea1fefb56 100644 --- a/js/src/forum/components/Search.js +++ b/js/src/forum/components/Search.js @@ -38,7 +38,7 @@ export default class Search extends Component { * * @type {SearchSource[]} */ - this.sources = this.sourceItems().toArray(); + this.sources = null; /** * The number of sources that are still loading results. @@ -74,6 +74,15 @@ export default class Search extends Component { this.value(currentSearch || ''); } + // Initialize search sources in the view rather than the constructor so + // that we have access to app.forum. + if (!this.sources) { + this.sources = this.sourceItems().toArray(); + } + + // Hide the search view if no sources were loaded + if (!this.sources.length) return
; + return (