adobe / aem-core-cif-components

A set of configurations and components to get you started with AEM Commerce development
Apache License 2.0
102 stars 80 forks source link

productcollection - addToWishlist and addToCart buttons not working for items loaded after 'load more' #985

Open jbaix opened 12 months ago

jbaix commented 12 months ago

Expected Behaviour

addToWishlist and addToCart buttons should work the same way for all items, those loaded from the server and after the 'load more' click event.

Actual Behaviour

For items loaded after the 'load more' click event, the buttons are not configured with the appropriate handlers, and the user is redirected to the product details page.

Reproduce Scenario (including but not limited to)

Configure a category page with 'Load more' option enabled.

Steps to Reproduce

Open a category page with products. Click on the addToCart, on any of the initial products loaded from the server side. The product is added to the cart. Click on the 'Load more' button. Click on the addToCart, on any of the products added to the list. The user is redirected to the product details page.

(repeat same steps for addToWishlist)

Platform and Version

Last AaaCS instance. CIF 2.12.2

Sample Code that illustrates the problem

No custom code involved.

Logs taken while reproducing problem

No logs in the browser developer tools

Additional notes

When the new items are appended to the galleryItems, no event handler is added to the addToWishlist and addToCart buttons. Please check ui.apps\src\main\content\jcr_root\apps\core\cif\components\commerce\productcollection\v2\productcollection\clientlibs\js\productcollection.js, line 139: galleryItems.append(...moreItems);