In Magento 2, I've seen that when we click on the button remove a product from the mini cart, we will be scrolled to the top of the site.
I've see that this one is because of <a href="#">
tag, and replace with <a href="javascript:;">
.
But that isn't enough, it still has the problem, so I've debugged it deeper and found that this confirm
from jquery have responsibility for this.
I just need to remove that confirm
code, and it won't scroll top anymore.
But unlucky that I can't find any solution to prevent the scroll to top from the confirm
jquery library.
Can someone help me please? Thanks.
Best Answer
I've debug deeper and found that this is because when you click on remove product button, magento modal use js to add
_has-modal
class to<body>
and also this activate some css related to_has-modal
class.For specific, this line is responsible for scroll top problem:
So i've create a css to override that part and it resolved the problem.
Hope it help someone who have this problem too.