Inconsistent behavior with Soft Limit's 'show more/show less' links

Created on 16 October 2023, about 1 year ago
Updated 10 July 2024, 5 months ago

Problem/Motivation

On a site we're using Search API Solr, and Facets for various taxonomy reference fields with the "List of checkboxes" widget. We're using the "Soft Limit" configuration for these facets so that we don't have to show the whole list of terms and that way we can make use of the "Show more/Show Less" links provided by the module's javascript. However, the behavior using the links is inconsistent if you have nested terms. In my case we wanted a soft limit of 5 items, then show the "Show more/Show less" links.

On initial page load we would see something like this:

This is showing 5 terms just as we configured in the "Soft limit" setting, and it appears to be basing the '5' to show based on the root level terms as it's showing all of the child items for each of these parent items.

Clicking show more expands the facet as expected and shows the rest of the available items for this facet.

However, clicking "Show less" leads us to where the inconsistency occurs.

You can see here now it's only showing literally 5 items. At this point you'll never get back into a state like when you first load the page as the show more/show less link will only account for showing literally 5 items (parents, children, etc.) or the full list.

Steps to reproduce

  • Create a taxonomy vocabulary with multiple parent and child terms. Create content type to reference these terms. Create search, add field, and create facet for utilizing the taxonomy. Ensure 'index heirarchy' is checked if using Solr.
  • Configure the facet to have a "Soft Limit" of any number greater than 1
  • Configure facet to "Use hierarchy" and have the "Always expand" checked so that the full tree is rendered.
  • After indexing and building a search page that shows the facets see the described behavior above.

Proposed resolution

The javascript that provides the show more/show less functionality should be consistent on first load and throughout the rest of the experience using the links to show/hide the rest of the facets.

Either it should always use the literal amount of the 'soft limit' to always only show that number of facets (including parent, child or grandchild, etc), or it should only consider the root level items when determining how the 'show more/show less' should behave.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States carsoncho Kansas City, MO

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

Comments & Activities

Production build 0.71.5 2024