Uncaught TypeError: Cannot read properties of undefined (reading 'settings')

Created on 10 January 2025, 8 months ago

Hi Team

I am on Drupal 10.3.9 and facets is 2.0.9.
I have product view with ajax filter , showing the filtered products.
I have checkboxes and customised range slider on my webpage.
Upon filtering I sometimes get the following error on console, the log message does not log any error.
I have custom module which is the based on facets-views-ajax.js

Uncaught TypeError: Cannot read properties of undefined (reading 'settings')
at updateFacetsView (VM129 facets-views-ajax.js:132:66)
at HTMLUListElement. (VM129 facets-views-ajax.js:115:17)

Regards
Divya

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India divya.lakshman

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

Comments & Activities

  • Issue created by @divya.lakshman
  • 🇺🇦Ukraine dunot

    It's because after an attribute has been clicked (in 1 product to multiple variations model),
    Drupal.views.instances object becomes undefined in facets-views-ajax.js.

    Fast workaround in facets-views-ajax.js is

    var views_arguments = Drupal.Views.parseViewArgs(href, 'search');
    + if (Object.keys(Drupal.views.instances).length === 0) { // if you changed the attributes in a product with several variations, the facet cannot be selected, therefore
    +      window.location.reload();
    +      return;
    +    }
    
Production build 0.71.5 2024