Woo Product Tabs - Reviews not displaying with Rating link
P
Paul Littlefield
The link to product Reviews generated from the 'Product Rating' element does not jump to the Reviews tabs on the 'Product Tabs' element.
Here is a page to demonstrate:-
I have tried to add the 'Reviews' element on the same Template but the #reviews anchor link is just ignored.
I am happy to either (a) be able to specify the #anchor link in the editor somehow and have my own reviews section, or have you fix the 'reviews' tabs issue.
Ben Hartlenn
Here's a bit of javascript you(and the Breakdance team) can use. I'm sure it could be improved, but it works good.
_____
if (document.querySelector('.bde-wooproducttabs') && document.querySelector('.woocommerce-review-link')) {
document.addEventListener('click', e => {
if (e.target.classList.contains('woocommerce-review-link')) {
// Remove active state from all tabs.
document.querySelectorAll('.bde-tabs__tab').forEach(tab => {
tab.classList.remove('is-active');
tab.setAttribute('aria-selected', 'false');
});
// Remove active state from all panels.
document.querySelectorAll('.bde-tabs__panel').forEach(panel => {
panel.classList.remove('is-active');
});
// Activate the Reviews tab.
const reviewTab = document.querySelector('#tab-woo-tabs-3');
if (reviewTab) {
reviewTab.classList.add('is-active');
reviewTab.setAttribute('aria-selected', 'true');
}
// Activate the Reviews panel.
const reviewPanel = document.querySelector('#tab-panel-woo-tabs-3');
if (reviewPanel) {
reviewPanel.classList.add('is-active');
}
}
});
}
_____
P
Paul Littlefield
Ben Hartlenn you absolute star! Thanks very much :-)