Problem:
The 18F website now shows a loading bar when results are loading. Using the renderJekyllPagesApiSearchResults hook, I am able to hide the loading bar when results are loaded. But I noticed that method that calls renderJekyllPagesApiSearchResults is guarded by a check to see if results == 0, it then returns from the method. See: https://github.com/18F/jekyll_pages_api_search/blob/master/assets/js/search-ui.js#L57
Solution:
Removing that return will allow execution to continue to renderJekyllPagesApiSearchResults and will allow for custom render functions to handle rendering when showing no results. It also works with default method.
For additional safety, we make sure to return array just in case SearchResults.results is not already an array.
Problem: The 18F website now shows a loading bar when results are loading. Using the
renderJekyllPagesApiSearchResults
hook, I am able to hide the loading bar when results are loaded. But I noticed that method that callsrenderJekyllPagesApiSearchResults
is guarded by a check to see if results == 0, it then returns from the method. See: https://github.com/18F/jekyll_pages_api_search/blob/master/assets/js/search-ui.js#L57Solution: Removing that return will allow execution to continue to
renderJekyllPagesApiSearchResults
and will allow for custom render functions to handle rendering when showing no results. It also works with default method.For additional safety, we make sure to return array just in case SearchResults.results is not already an array.
This approach is being used on the 18F website and this pull request solves our problem. More info here: https://github.com/18F/18f.gsa.gov/blob/add-loading-bar-to-search/assets/js/jekyll-pages-api-search.js#L10