Bug on search after having some handlers

I have updated, but that doesn’t fix the search bug, basically if the home page is another thing than the blog feed, then the search continue showing the home page
this happens with my theme, but also with twentytwenty
the search doesn’t show isSearch

Sorry, @alexaspalato, I meant that the bug related to isHome is fixed. :sweat_smile:

Regarding the isSearch issue, the problem is that handlers are the ones responsible for adding that property and return the search result. When a static page is shown as the homepage, the handler being executed for the root link (/) is postTypeHandler, which ignores the search query. As the <SearchForm> component is using /?s= to build the link with search query, it doesn’t work for static homepages.

To fix this you can modify the <SearchForm> component in /src/components/search/search-form.js so it uses state.source.postsPage when building the link with the search query.

// Let's go search for blogs that match the search string
  `${state.source.postsPage || "/"}?s=${searchString.toLowerCase()}`

That way the handler executed is the one for the post archive, which already has the logic for searches.

This is a bug anyway, either in wp-source handlers or in twentytwenty-theme.

I’ll open an issue in our repo.

@alexaspalato, I forgot to mention, as handlers are in charge of honor the search query, you would have to add support for that in your featuredCatHandler as it is the one being executed for the root link (/).

Juanma already explained how to do so:

@juanma @David Thank you!
I tried to apply these changes in order to make the search work but it gives an internal server error
So for the moment I deactivated the search as it’s not mandatory for the client
and had what I tried to do on this branch