components icon indicating copy to clipboard operation
components copied to clipboard

How to programmatically close alert from non-click event?

Open chrisspen opened this issue 4 years ago • 0 comments

The docs show you can close an alert by calling the aptly named closeAlert() from an alert button's onclick event.

However, I'd like an alert to be closed by pressing the Esc key, yet there seems to be something blocking the escape key press from reaching my custom keypress handler, even though all other key presses are being registered.

Even then, if I call closeAlert() from the Javascript console, it does nothing except return the error:

Cannot read property 'target' of undefined

Is there any native support for closing alerts using the escape key? And if not, how do I disable whatever built-in logic is catching and blocking the escape keypress from being registered in a custom handler, and call closeAlert() myself?

chrisspen avatar Mar 16 '21 00:03 chrisspen