[FIX] website_sale: show the list of products from the price range selected

Steps to reproduce:
1. Go to website shop page
2. Change the price sliders so no products are shown
3. Increase the range of the sliders

Issue:
Traceback

```python
UncaughtPromiseError > TypeError
Uncaught Promise > Cannot read properties of null (reading 'classList')
TypeError: Cannot read properties of null (reading 'classList')
at Class._onPriceRangeSelected (https://23198922-16-0-all.runbot173.odoo.com/web/assets/debug/1/web.assets_frontend_lazy.js:121254:70) (/website_sale/static/src/js/website_sale.js:1200)
at HTMLInputElement.<anonymous> (https://23198922-16-0-all.runbot173.odoo.com/web/assets/debug/1/web.assets_frontend_lazy.js:72834:23) (/web/static/src/legacy/js/core/mixins.js:277)
at HTMLDivElement.dispatch (https://23198922-16-0-all.runbot173.odoo.com/web/assets/debug/1/web.assets_frontend_lazy.js:26934:27) (/web/static/lib/jquery/jquery.js:5183)
at elemData.handle (https://23198922-16-0-all.runbot173.odoo.com/web/assets/debug/1/web.assets_frontend_lazy.js:26742:28) (/web/static/lib/jquery/jquery.js:4991)
at Multirange.dispatchNewValueEvent (https://23198922-16-0-all.runbot173.odoo.com/web/assets/debug/1/web.assets_frontend_lazy.js:122060:24) (/website/static/lib/multirange/multirange_custom.js:258)
```

Cause:
When the list of products is empty, the div containing it is no longer present. So when we try to get it with querySelector() it returns null.

Solution:
Ensure the div is present in the DOM to modify it

opw-3144545

closes odoo/odoo#112150

X-original-commit: 2d34cd6fa2cc3f04f86712f709f5503cb5373631
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Eteil Djoumatchoua (etdj)
2023-02-14 17:09:25 +01:00
parent 8efa991f0a
commit 93bfbdf558
@@ -1241,7 +1241,10 @@ publicWidget.registry.multirangePriceSelector = publicWidget.Widget.extend({
if (parseFloat(range.max) !== range.valueHigh) {
search['max_price'] = range.valueHigh;
}
this.el.querySelector('.o_wsale_products_grid_table_wrapper').classList.add('opacity-50');
let product_list_div = this.el.querySelector('.o_wsale_products_grid_table_wrapper');
if (product_list_div) {
product_list_div.classList.add('opacity-50');
}
window.location.search = $.param(search);
},
});