Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search is only working on new page loads #978

Conversation

javiergamarra
Copy link
Contributor

@javiergamarra javiergamarra commented May 1, 2021

Hi!

This should fix this and this. And some other small things (in the commit messages). I can split/format the PR any way you like :D

The search issue is due to this. I would remove the plugin because it's doing almost nothing right now and use custom code. I've replaced the harcoded key with a variable: process.env.ALGOLIA_KEY so for it to work you have to define it in your properties (or hardcode it again, it's safe to leak as it's designed to be used in frontend apps).

If you have any doubts/issues, please let me know! :)

With the key it should work like this:

Apr-30-2021 23-46-36

…d bad hardcoding it inside a component) and add useEffect to re-apply search in first render. The current plugin uses a mutation observer that is loaded with a DOMContentLoaded event that does not fire on the pure JS page transitions in Gatsby. So when you navigate to another page, the plugin does not try to find the search input box.
… and… I do not understand why/how is this being used. I guess it’s a C&P error from setting the prop in the component just before.
…ience with Gatsby) but you are using order as the key to an iteration in React and this is not fine for React and causes all sort of problems. See https://reactjs.org/docs/lists-and-keys.html#keys.
…etting any key. Newsletters won’t work of course.
@netlify
Copy link

netlify bot commented May 1, 2021

Deploy request for happy-jackson-1b6bb8 accepted.

Accepted with commit abc910f

https://app.netlify.com/sites/happy-jackson-1b6bb8/deploys/608d3a7294378f0007ca57a2

Copy link
Member

@plhnk plhnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow thanks so much @nhpatt!!

for all the work, of course, but also for the really thorough explanations — really helpful!

@plhnk plhnk merged commit 12ea530 into liferay-design:master May 3, 2021
@javiergamarra
Copy link
Contributor Author

Thanks for merging :D But it's failing in production because it can resolve the process.env variable :'(

I'll send a PR hardcoding it, that way it will be safer than rely on configuration files.

@plhnk
Copy link
Member

plhnk commented May 3, 2021

ah — I set it in Netlify...that should have solved it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search bar not working in liferay.design/lexicon reference site
2 participants