Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong focus after closing a 2nd modal

I'm using vue.js 2 and bootsrap 3 to open a modal that opens a 2nd modal.

Few days ago, I asked a question on how to set a focus on a control contained in a 2nd modal. I got a great answer that solved the issue.

Problem When opening the 1st modal, the user is able to scroll through it to see its bottom. But after opening and closing the 2nd modal, the focus moves to the page that contains the 1st modal. and when the user scrolls to see the rest of the 1st modal, he scrolls the page behind that 1st modal.

It is very uncomfortable to use especially when the modal is bigger than the screen height. Is there a way to prevent this?

To reproduce this issue, open the answer and click on "Expand snippet"

like image 645
Warrio Avatar asked Sep 08 '17 11:09

Warrio


1 Answers

That work for me:

$('#my-modal').on('hidden.bs.modal', function () {
        $('body').addClass('modal-open');
    });
like image 161
Shir Avatar answered Sep 22 '22 11:09

Shir