1

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.

enter image description here

I've see that this one is because of <a href="#"> tag, and replace with <a href="javascript:;">.

enter image description here

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.

enter image description here

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.

1 Answer 1

1

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:

body._has-modal {
   overflow: hidden;
}

So i've create a css to override that part and it resolved the problem.

body._has-modal {
    overflow: initial;
}

enter image description here

Hope it help someone who have this problem too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.