Clicking on search suggestions not working
-
In the Lay Theme, after typing a few letters in the search input, a list with suggestions is shown. It is however almost impossible to select the text from the suggestions by clicking, because the list is hidden before the click event is handled.
A solution to make it work is to register the blur even not on the input, but on it's parent. So instead of:
events: {
"input #search-query": "onInput",
"focus #search-query": "onFocus",
"blur #search-query": "onBlur",
"click .close-search": "onHide"
},
The blur event can be set on the .search-inputs selector:
events: {
"input #search-query": "onInput",
"focus #search-query": "onFocus",
"blur .search-inputs": "onBlur",
"click .close-search": "onHide"
},This way the blur event only occurs when the focus of all the search components is lost. Clicking on the suggestions will not trigger the blur, which in my opinion should not be done as the suggestions are part of the search input.
-
hey there so you'd like to be able to copy the suggestion?
why would you want to copy it?you can just click on them to make the search overlay search for that text
-
Hello, thank you for your reply.
I want to fill the text from the suggestion in the search input. This often doesn't work.
The problem is when I try to click a suggestion the blur event from the search input hides the suggestions before the click event is handled. So only when the click event is triggered within 100ms it works. I see that blur only works on inputs, not on div elements, so maybe the delay for hiding must be longer.
-
oh really
what is your website address
-
I fixed the issue on the main website, but on the test site I reverted the modification. You can check the problem here: https://new.pakhaus.nl/
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it