Dialog closing with Escape - Safari

Hello,
I have an issue with closeOnEsc function on dialog. If I enable it and I use Escape key in browser the dialog is correctly closed but also browser window is minimized. This issue is probably specific for MacOS and it’s way of “fullscreaning”.
But if I use clearbox on my website the esc key only closes the clearbox (the window remains maximized). As the dialog API doesn’t allow override escape key event to preventDefault or something like that - I am short with solutions.
Is there any elegant solution for this? I know I could use some kind of custom keyboard JS event registration, but is it the only way? Is there a chance for this to be “improved”?

Thx
JS