baralbishwas07 / Mero-Store

Mero-Store : An e-commerce platform
0 stars 0 forks source link

Issue with consecutive 'Add to Cart' button clicks #1

Open baralbishwas07 opened 4 months ago

baralbishwas07 commented 4 months ago

Issue Description

There is a problem with the 'Add to Cart' button functionality when clicked consecutively for different products.

Steps to Reproduce

  1. Click the 'Add to Cart' button for one product.
  2. Quickly click the 'Add to Cart' button for another product.
  3. Notice that the first product's "added to cart" message does not disappear.

Expected Behavior

Each product's "added to cart" message should disappear after the timeout, even when buttons are clicked consecutively.

Code Snippet


const addedMessage = document.querySelector(`.js-added-to-cart-${productId}`);
addedMessage.classList.add('style-addedMessage');

clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
  addedMessage.classList.remove('style-addedMessage');
}, 2000);
iamaakashbasnet commented 4 months ago

Kool