Here's a clever solution:
The accordion button is equipped with a key data attribute
data-bs-collapse="collapse"
Without this key, the accordion simply won't function. So, we can take advantage of this by using it to disable the accordion when hovering over our own button.
In essence, we can:
on mouseenter event of your button, set the accordion button's data-bs-collapse
to an empty string ""
on mouseleave event of your button, revert the accordion button's data-bs-collapse
back to "collapse"
Assuming your button is a direct child of the collapse button/div, here's a snippet of code:
yourButton.addEventListener('mouseenter', (e) => {
let accordionButton = yourButton.parentElement;
accordionButton.setAttribute('data-bs-toggle', '');
});
yourButton.addEventListener('mouseleave', (e) => {
let accordionButton = yourButton.parentElement;
accordionButton.setAttribute('data-bs-toggle', 'collapse');
});
yourButton.addEventListener('click', (e) => {
// carry out your desired actions...
});
Trust this comes in handy!