Empty facets still shown with patch from facets ajax issue 3052574

Created on 19 October 2021, about 3 years ago
Updated 15 April 2024, 7 months ago

Problem/Motivation

There is a long running patch for ajax compatibility. The latest patch introduces some issues with this module because of the way the render array changes.

Steps to reproduce

Use patch from https://git.drupalcode.org/project/facets/-/merge_requests/26.diff
Add facets that are empty in the block and see that they are still shown.

Proposed resolution

Change

          if (!$build) {
            $is_empty = TRUE;
          }
          elseif (isset($build[0]['#attributes']['class']) && in_array('facet-empty', $build[0]['#attributes']['class'])) {
            $is_empty = TRUE;
          }
          // Check if Summary Facet is empty.
          elseif (isset($build['#items']) && count($build['#items']) == 0) {
            $is_empty = TRUE;
          }
🐛 Bug report
Status

Postponed

Version

2.0

Component

Code

Created by

🇳🇱Netherlands jefuri

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France GaëlG Lille, France

    GaëlG made their first commit to this issue’s fork.

  • @ga%C3%ABlg opened merge request.
  • Status changed to Postponed 7 months ago
  • 🇫🇷France GaëlG Lille, France

    I first updated MR !2, then I found out that MR !2 was (wrongly it seems) against 1.x. So I made MR !12 with the same changes but against 2.0.x

    I switch the issue status to postponed as 🐛 Facets with AJAX not working in most of situations Needs review is not committed for now.

  • 🇫🇷France GaëlG Lille, France

    Actually it's much more complicated, because if a facet is not empty on initial page load, but empty after AJAX reload (because another facet has been used), the empty facet will still appear (it's title at least). The whole facets block should be recomputed on AJAX reload, but it's not the case.
    Actually, I'm not sure this module is so useful, as blockgroup can do kinda the same.

Production build 0.71.5 2024