Created
May 4, 2022 23:46
-
-
Save Acen/adc12e772e7843722b11c1a14ff6428b to your computer and use it in GitHub Desktop.
Shopify Review - on click go to tab & scroll into view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if block.type == 'reviews' %} | |
<script> | |
document.querySelector('.spr-starrating').classList.add('cursor-pointer') | |
document.querySelector(`div.spr-summary-starrating`).onclick = function (e) { | |
Array.from(document.querySelectorAll('.sf-tab-header')).find(el => el.textContent.includes("Product reviews")).click(); | |
setTimeout(function(){ | |
document.querySelector('div[data-id="{{ product.id }}"]').scrollIntoView(); | |
}, 200) | |
} | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment