- Issue created by @ifrik
- πΊπ¦Ukraine khiminrm
I need this feature too.
As a quick solution I've taken javascript from the facet's module soft-limit.js, modified it to use hardcoded limit, labels, selectors and used it in custom theme. But still need to exclude some filters.function softLimit() { // Soft limit. var limit = 15; var zero_based_limit = (limit - 1); var facetsList = $('..bef-checkboxes'); // Hide facets over the limit. facetsList.each(function () { var allLiElements = $(this).find('.form-check'); $(once('applysoftlimit', allLiElements.slice(zero_based_limit + 1))).hide(); }); // Add "Show more" / "Show less" links. $(once('applysoftlimit', facetsList.filter(function () { return $(this).find('.form-check').length > limit; }))).each(function () { var facet = $(this); var showLessLabel = Drupal.t('Show less'); var showMoreLabel = Drupal.t('Show more'); $('<a href="#" class="facets-soft-limit-link"></a>') .text(showMoreLabel) .on('click', function () { if (facet.find('.form-check:hidden').length > 0) { facet.find('.form-check:gt(' + zero_based_limit + ')').slideDown(); facet.find('.form-check:lt(' + (zero_based_limit + 2) + ') a, .form-check:lt(' + (zero_based_limit + 2) + ') input').focus(); $(this).addClass('open').text(showLessLabel); } else { facet.find('.form-check:gt(' + zero_based_limit + ')').slideUp(); $(this).removeClass('open').text(showMoreLabel); } return false; }).insertAfter($(this)); }); }
- π³πΏNew Zealand dieuwe Auckland, NZ
This would be a great feature, one of the few things missing out of the box with Facets 3 integration with BEF.
The sample JS code there was very helpful for a temporary custom implementation, just a note that "form-item" is the class I needed on my theme as I don't have "form-check" (another option would have been "form-type-checkbox").
- First commit to issue fork.
- π§πͺBelgium StryKaizer Belgium
Feature pushed in branch. Needs review
For now, works for radios/checkboxes widget and links widget. - Merge request !1623504532 Soft limit for radios/checkboxes and links β (Open) created by StryKaizer
- πΊπΈUnited States smustgrave
Thanks for working on it! Will need an update hook for the new keys + schema
- πΊπΈUnited States smustgrave
Rock on! I'll put it top of my list for this week, may be able to get a relase out Friday.
- First commit to issue fork.
- πΊπΈUnited States kmonty San Francisco, CA
The ESLint job is now passing. If I have more time at ddd2025, I'll also strip out jQuery in favor of vanilla ECMA 2020 JS.
- πΊπΈUnited States kmonty San Francisco, CA
Fixed all outstanding build issues.
Resolved a PHPCS failure unrelated to this ticket in π Resolve PHPCS issues in 7.1.x-dev Active
- πΊπΈUnited States kmonty San Francisco, CA
Rolling back my lint fixes at the request of the maintainer.
- πΊπΈUnited States smustgrave
Looking good, think we just need test coverage
- π³π±Netherlands ifrik
This is not working for me, neither on my existing site nor on a clean Drupal 11 with just Search API and Facets 3 as additional modules.
I see the soft limit as an option in the Better Exposed Filters config for my facet, but all items keep on being displayed.
How have you been testing that yourself? So maybe there's a difference in the config that gets in the way.
- π§πͺBelgium StryKaizer Belgium
underscores issue addressed.
Still needs tests - π³π±Netherlands ifrik
Thanks! This works for me now if the filter widget is set to "Links" but not if it's set to display "Checkboxes/Radiobuttons"
- π³π±Netherlands ifrik
Testing it with a hierarchical facets: This creates two links to "show more".
It would be a better UX if the soft limit would only apply to the top level of hierarchical facets. By selecting one of the top level ones, the user has already committed themselves to drilling down further, and will be clicking on "show more" for the second level anyway.
- π§πͺBelgium StryKaizer Belgium
Good! It looks like this feature only needs tests now.