Is there a way to handle the back button pressed on a mobile device when a modal dialog is open?
The problem is when a modal is shown and the back button it pressed it will either close the browser or navigate back to a previous page rather than simply exit out of the modal.
This seems to work ok, user can exit out of the dialog normally and also pressing back browser button or back on smartphone also just closes the dialog and doesn't navigate away. Hopefully a better solution could be implemented by Radzen at some point as I've seen other Bootstrap solutions that use jquery to handle this and they seem to work quite well such as
..my script below.
function AddModalToHistory(url) {
window.history.pushState("Modal", "", url);
}
window.onpopstate = function (e) {
if (e.state == "Modal") {
window.history.back();
}
};