Facets - JsonApiResponseWidget widget only renders the first 2 levels of taxonomy when using "Use hierarchy" option

Created on 17 November 2023, 11 months ago

Problem/Motivation

I created a facet which uses a taxonomy reference field and I want to display the whole hierarchy in my widget. The problem is that JsonApiResponseWidget from jsonapi_search_api_facets submodule has some broken code and only takes into consideration the children of the first level terms. The buildListItems method is missing the recursive call.

Steps to reproduce

Make sure you have a taxonomy with multiple levels and terms from all levels are referenced from a content type and indexed in the search api index.

Create a facet using a "JSON:API Search API Facets" source. Choose a taxonomy term reference field. Check the "Use hierarchy" option within Facet settings.

Proposed resolution

Refactor the buildListItems method in JsonApiResponseWidget.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇷🇴Romania tavib47

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tavib47
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 11 months ago
    Waiting for branch to pass
  • @tavib47 opened merge request.
Production build 0.71.5 2024