[FIX] website_sale_aplicoop: prevent grid destruction on event listener attachment

The _attachEventListeners() function was cloning the products-grid element
without its children (cloneNode(false)) to remove duplicate event listeners.
This destroyed all loaded products every time the function was called.

Solution: Use a flag (_delegationListenersAttached) to prevent adding
duplicate event listeners instead of cloning and replacing the grid node.

This fixes the issue where products would disappear ~1-2 seconds after
page load.
This commit is contained in:
snt 2026-02-18 16:53:27 +01:00
parent b15e9bc977
commit b07b7dc671
6 changed files with 521 additions and 218 deletions

View file

@ -48,7 +48,17 @@
"assets": {
"web.assets_frontend": [
"website_sale_aplicoop/static/src/css/website_sale.css",
# i18n and helpers must load first
"website_sale_aplicoop/static/src/js/i18n_manager.js",
"website_sale_aplicoop/static/src/js/i18n_helpers.js",
# Core shop functionality
"website_sale_aplicoop/static/src/js/website_sale.js",
"website_sale_aplicoop/static/src/js/checkout_labels.js",
"website_sale_aplicoop/static/src/js/home_delivery.js",
"website_sale_aplicoop/static/src/js/checkout_summary.js",
# Search and pagination
"website_sale_aplicoop/static/src/js/infinite_scroll.js",
"website_sale_aplicoop/static/src/js/realtime_search.js",
],
"web.assets_tests": [
"website_sale_aplicoop/static/tests/test_suite.js",