Shopify filters Auto-Close Previous Filters

Topic summary

A Shopify store owner wants filters to auto-close when opening a new one, rather than having multiple filters remain open simultaneously.

Current Issue:

  • When opening a filter (e.g., color), previously opened filters (e.g., price) stay open
  • Desired behavior: only one filter section open at a time

Solution Provided:
A JavaScript code snippet was shared that:

  • Targets details.accordion elements
  • Automatically closes previously opened filters when a new one is clicked
  • Manages aria-expanded attributes for accessibility

Status:
The solution has been provided with a visual demonstration (GIF). The original poster is seeking clarification on where exactly to add the script in their Shopify theme. The discussion remains open as implementation guidance is still being requested.

Summarized with AI on November 3. AI used: claude-sonnet-4-5-20250929.

1734511985983-20241218_163518.gif