getgrav / grav-plugin-simplesearch

Grav SimpleSearch Plugin
https://getgrav.org
MIT License
44 stars 55 forks source link

Broken due to behaviour change (?searchfield=X) #154

Closed Perlkonig closed 6 years ago

Perlkonig commented 6 years ago

My site was running great, including search. I hadn't touched the install for over a year. I finally went to upgrade everything: Grav core first, then the plugins. Everything appeared to upgrade fine, but then search suddenly stopped working. (I should note that GPM is installing version 1.14.1, even though the "latest release" is 1.12.0.)

I have the search box in my sidebar. Typing the text and hitting enter used to redirect to the search page and show me results. Now it simply adds a ?searchfield=X query to the end of whatever URL I'm at, which of course does nothing. I'm still staring at the page I was on. If I manually type in the URL (/search/query:X), then it works as expected.

I've customized simplesearch_item.html.twig, but nothing else. I see no mention of this behaviour change in the docs. Any advice would be appreciated.

Thanks!

kenton-r commented 6 years ago

you need to load the js. {% do assets.addJs('plugins://simplesearch/js/simplesearch.js') %}

Perlkonig commented 6 years ago

I'm afraid that didn't work.

https://www.perlkonig.com/dev/?searchfield=grain

The JS is indeed loading. Again, if I manually configure the URL, it works as expected.

https://www.perlkonig.com/dev/search/query:grain

But if I type anything else in the search box, I get the original problem.

https://www.perlkonig.com/dev/search/query:grain?searchfield=chocolate

rhukster commented 6 years ago

It must be something with your custom twig for the search. In all our demos that use the plugin-provided search twig, things work fine, and this param is not added. Test this by renaming your custom twig and see if that gets things working again?

Perlkonig commented 6 years ago

Well I'm flummoxed. Deleting the one custom twig doesn't fix it. And the only place the text "searchfield" appears anywhere is in the simplesearch folder:

./user/plugins/simplesearch/templates/partials/simplesearch_searchbox.html.twig
./user/plugins/simplesearch/js/simplesearch.js

Maybe it's some interaction with the new plugin and the base theme (TwentyFifteen, which hasn't been updated in two years)? It was working fine until I updated.

Well, I keep meaning to just create my own theme from the ground up, so I guess I'll get on that and assume it will work fine out of the box.

Perlkonig commented 6 years ago

Starting a new theme from scratch seemed to work fine. One day I'll do a clean twenty-fifteen install and see if the issue still happens. Bizarre.