Jetpack: Instant Search: taxonomy filters not being applied to results

Created on 17 Jan 2020  路  2Comments  路  Source: Automattic/jetpack

Steps to reproduce the issue

  1. Follow the newly updated testing instructions which requires adding a Jetpack Search widget into the overlay widget area (named Jetpack Search Sidebar). Please make sure to configure some search filters for this widget, including a taxonomy filter: Tag, Category or Post Type.
  2. Perform a site search to trigger the Jetpack Search overlay.
  3. Check a Tag, Category or Post Type filter.

What I expected

Checking a Tag, Category or Post Type filters the search results by the selected option.

What happened instead

Checking a Tag, Category or Post Type filter changes the query string, but does not alter the results.

Screen Shot 2020-01-17 at 15 08 28

Instant Search Search [Type] Bug

All 2 comments

This was happening because I had two Jetpack Search widgets set up - one in the footer, and one in the overlay. The code currently uses the first widget it finds in getFilterKeys():

https://github.com/Automattic/jetpack/blob/7ee491958b6652baa38bcad791f2a36b151e504d/modules/search/instant-search/lib/query-string.js#L151

In my case, it was using the wrong widget and so didn't have the full list of filters. This meant it did not react to any query string changes for post_tag and post_format, for example. The 'Clear Filters' button also didn't work correctly, only clearing the filters it knew about.

Two possible solutions to this:

  1. Find a more reliable way to get the current widget's filters in getFilterKeys().
  2. Prevent the widget from being added to widget areas other than the overlay / only allow the widget to be added once.

cc @jsnmoon

Good catch, @bluefuton. I'll spin up a fix for this issue.

Was this page helpful?
0 / 5 - 0 ratings