# How to prevent going back when back button is pressed while modal is open?

**URL:** <https://forum.ionicframework.com/t/how-to-prevent-going-back-when-back-button-is-pressed-while-modal-is-open/223477>\
**Category:** Ionic React\
**Created:** [May 22, 2022, 9:06pm UTC](https://forum.ionicframework.com/t/how-to-prevent-going-back-when-back-button-is-pressed-while-modal-is-open/223477 "2022-05-22T21:06:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LarsFlieger](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@LarsFlieger](https://forum.ionicframework.com/u/LarsFlieger)\
**Post date:** [May 22, 2022, 9:06pm UTC](https://forum.ionicframework.com/t/how-to-prevent-going-back-when-back-button-is-pressed-while-modal-is-open/223477/1 "2022-05-22T21:06:04Z")

</div>

I’m using a `IonModal` on my page. When the modal is open and the user clicks back (on browser back button). It goes back to the previous page (instead of closing the modal / or doing nothing).

How can I prevent Ionic from doing this behavior?

I want either

1. Close the modal (with back)
2. Do nothing
