Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In a facet with the LinksWidget and an expanded hierarchy (with taxonomy terms), when I select only a children (not a first level item), the reset link is active (with the class is-active). I join a screenshot to demonstrate it.
The problem seems to be in \Drupal\facets\Plugin\facets\widget\LinksWidget, line 84
// Check if any other facet is in use.
$none_active = TRUE;
foreach ($results as $result) {
if ($result->isActive()) {
$none_active = FALSE;
break;
}
}
// Add an is-active class when no other facet is in use.
if ($none_active) {
$item['#attributes'] = ['class' => ['is-active']];
}
This loop check only the first level, not for the childrens inside a Result.
To make it work with a hierarchy we will need something like
foreach ($results as $result) {
if ($result->isActive()) {
$none_active = FALSE;
break;
}
if ($childrens = $result->getChildren()) {
foreach ($childrens as $children_result) {
if ($children_result->isActive()) {
$none_active = FALSE;
break;
}
}
}
}
But this is not recursive, and not ready.
I will try to propose a patch soon (probably end of the week).
Comment | File | Size | Author |
---|---|---|---|
#3 | 3063921-3-reset-link-is-active-when-only-child-selected.patch | 391 bytes | Evaldas Užkuras |
Reset link is active when a children is selectionned.png | 52.96 KB | pierre-nono |
Comments
Comment #2
borisson_Have you found a solution for this? The approach you outlined in the issue seems like a good start.
Comment #3
Evaldas UžkurasComment #4
borisson_This sounds like a good solution - I'm not sure if we need tests for this because it's a really simple fix.
Comment #5
c.altosax CreditAttribution: c.altosax commentedThis issue is still present in version 8.x-1.6. The patch in #3 works for me, and simple testing did not reveal any undesirable side-effects. I would love to see this fix merged in.
Comment #6
jannakha CreditAttribution: jannakha as a volunteer and at Tomato Elephant Studio commentedpatch works!
Comment #8
mkalkbrennerCommitted, thanks for your help!