Returning to Where It All Began

Status report: working again on the Search page

Royce Ayroso-Ong
2 min readApr 17, 2021
Photo by Sylwia Bartyzel on Unsplash

Before I begin, I’d like to make a shout-out to Abdul (@HyperTHD) for working on this PR right here. By creating a SearchContext, passing props and hooks across SearchPage’s many components have never been so easy.

I actually held off on doing this PR because I was unsure of how to go about it. The way I did the initial SearchHelp logic was that if the user clicked the search button it will trigger the onSubmit() hook, which is where I also called my function to hide the SearchHelp component. Thus, every time the user searched for something it would hide the SearchHelp. This worked sort of well, but what happens if the user searches for something and no results pop up? Maybe they mishandled their search and they don’t know where they went wrong. Or perhaps after a long session of searching, the user may have forgotten the nuances of the search syntax and needs a reminder. Both of these scenarios show that the SearchHelp component needs to be visible when an invalid or empty search is called. The main problem was that the hook that I created to handle the visibility of the SearchHelp was in the SearchProvider component but the logic for handling invalid searches was found in the SearchResults component. I was unfamiliar with React hooks to begin with, and now I needed to somehow pass the state and the hook for the SearchHelp through layers of component parameters. This is where Abdul’s SearchContext comes in handy — instead of passing multiple pieces of data as props through a variety of different components, you can simply import the pieces of data via the SearchContext right in the file where it needs to be used. Thanks to him I was able to focus more on how the logic would behave rather than fighting the layers of component structure and dependencies.

Other than that, I’ve almost got this PR ready to merge, just a couple more adjustments to satisfy the design community within Telescope and I’ll be set. Getting these two pull requests merged will be my plan for the weekend, as well as getting more issues completed for accessibility-related stuff. Since we are nearing the release of Telescope 2.0, I need to get on the accessibility issues right away to be able to merge anything by the release date.

--

--

Royce Ayroso-Ong

Student at Seneca for Software Development. Stay awhile, and lets learn something new together!