FIX: do not respond to pressing ESC and ENTER if we're NOT on the modal (PR #13424)

Our modals always respond to pressing ESC and ENTER (we handle the keyUp event). The problem is that sometimes some code can handle the keyDown event (for Ctrl+Enter for example) and close the modal before handling the keyUp event in the modal. With the current implementation, it leads to one more accepting or dismissing of the modal.

This PR fixes this problem, we’ll be responding to pressing ESC or ENTER only when we’re on the modal.


@pmusaraj sadly I should close it. It introduces new problems. In fact, the keyUp event is pretty often fired with <body> as a target. In these cases, my fix breaks the current behaviour of modals (they won’t close by ESC and won’t trigger a primary action by ENTER)

There’ll be a PR with another fix later.