From 93bfbdf55816bcd6c60efcc4f290982ab2e6f98a Mon Sep 17 00:00:00 2001 From: "Eteil Djoumatchoua (etdj)" Date: Tue, 31 Jan 2023 13:41:42 +0000 Subject: [PATCH] [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. (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) --- addons/website_sale/static/src/js/website_sale.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 44f405d9c26..e08ba8c73a1 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -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); }, });