Site logo

Archived topic

Search bar focus

10 replies · Started by Gianluca on March 3, 2020

Viewing posts 1–11 of 11

Hi,
I have a problem with my search bar: when I click on the search icon, the search bar opens but the cursor is not displayed and if I try yo type someting to search it doesn't work, but I have to click inside the search barr to be able to write someting.

Please, can you help me?

Hi there,

That's weird. It should work like that by default as you can test it here:
https://gpsites.co/marketer/

Any chance you can disable all plugins except GP Premium to eliminate conflicts from other plugins first?

Make sure you are using the parent theme with no custom CSS or functions added as well.

Let me know :)

Hi Leo,
thank you for your replay.

I found the problem: is the function "generate_smooth_scroll_elements" that, when enabled, causes the bug in the search bar. I'm using the code that I found on your site here https://docs.generatepress.com/article/generate_smooth_scroll_elements/

I need this function, but I need also that the search bar work properly.

How can I fix the error?

Hi there,

not sure if this will work but try this code:

add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
  $elements[] = 'a[href*="#"]:not([aria-label*="Apri"])';
  
  return $elements;
} ); 

Hi David,
I replaced :not with .not and it worked.

Tank you very much!

Sorry but with .not while now the search bar work, all the smooth scroll links on my website don't work anymore.

However with :not the smooth scroll links work but the search bar not. :(

Do you have any other suggestions for me?

TY.

You may need to be more specific with your targeting.

For example, if the links you're targeting are in the content area, you can do this:

add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
  $elements[] = '.entry-content a[href*="#"]';
  
  return $elements;
} ); 

Thank you Tom, it works well.

But if I want to add the links positioned in other zone of the site (for example in the .page-hero), how can I add a second position?

Try this:

add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
  $elements[] = '.entry-content a[href*="#"]';
  $elements[] = '.page-hero a[href*="#"]';
  
  return $elements;
} ); 

Thank you Tom, it works very well!

You're welcome :)

This archived topic is closed to new replies.