Slide menu closed before the modal when I clicked on mobile back button


#1

I have slide menu that has a list of buttons. Some buttons open modal instead of root page.

My problem is:
when I opened the modal and try to go back by using mobile back button, then I must double tap on back button to close the modal

I find the reason but I could find the solution:

The reason is : this issue happens because the first tap close the slide menu instead of modal. Then the second tap close the modal.

So How can I let the application close the modal first when I click on back button of mobile ?