Answers search-bar dissapear sometimes

Hi,

we have a strange case whith Answers in a customer company.

What happens is relatively curious. If you put the URL directly in a browser: https://www.pelayo.com/seguros-moto/ciclomotores the search-bar appears.

However, if you browse the web and arrive at that same page, then the search-bar is not displayed.

image

Any idea??

Thanks.

Regards,

David

Hi David,

That is strange! Can you give more detail on how you arrived at the page in the second screenshot? I tried to Google “pelayo Seguro de ciclomotor” and arrived at the URL you provided above, but saw the search bar was still there. I inspected the HTML and the integration code looks correct to me, so any detail you give will help us troubleshoot. One thing I’m wondering is if both screenshots are for the same page URL seeing as how the top of the second screenshot has icons while the first doesn’t. Let me know!

Hi Kristy,

Yes, it is a very strange case!

  1. Go to pelayo.com

  2. In the top menu, click (there are several drop-downs) on Seguros, Moto and Seguro ciclomotor.

  3. This loads the page but without the search bar…

  4. If an F5 is done in the browser then the bar does load

Thanks!

Hi David,

I was able to recreate the issue with those steps. One interesting thing I noticed between the page with the search bar and the page without is that the initAnswers function is not showing up in the page without the search bar.

Can you try to update the search bar library initialization to the code provided in this step? Particularly, there are a few differences:

  • Move the answerstemplates.compiled.min.js script before the initAnswers script. I’m wondering if the search bar is not appearing because this may need to be loaded before the search bar is actually initialized.
  • There are two scripts and one stylesheet that reference the answers-search-bar library, however I see you are using the answers library in your code. I’d recommend switching to the search bar only component, which will also speed up your search performance. Based on the change log linked, it looks like we’re on version 1.3.

For example, the following in your code

<link href="https://assets.sitescdn.net/answers/v1.11/answers.css" rel="stylesheet" type="text/css">

would become

<link href="https://assets.sitescdn.net/answers-search-bar/v1.3/answers.css" rel="stylesheet" type="text/css">

Let us know if these changes work for you!

Hi Kristy,

the problem was solved yesterday . This was an issue entirely outside of Yext, one of the caches that Liferay works with was causing that effect the first time the page was accessed.

That cache was adjusted in Liferay and the problem is totally solved.

Thanks again for your help!

Regards,

David