I have successfully implemented a sticky add to cart feature on my Shopify store. However, there seems to be an issue where clicking on the variations in the sticky area also triggers the same variations on the product page, making it difficult for users to navigate. I used the click method to achieve this interaction, but it also scrolls the viewport to the top of the page when the button is clicked. Is there a way to prevent this behavior?
Thank you.
Javascript code on the product page:
document.querySelectorAll(".product-form__input.sticky label[class='tooltip']").forEach((input) => {
input.addEventListener('click', function(e){
document.querySelector("label[for='"+e.target.getAttribute("data-target-option")+"']").click();
});
});
Variants.js:
// Code for updating variant selects and radios goes here...