79683881

Date: 2025-06-29 16:20:07
Score: 1
Natty:
Report link

As of Chrome 134 (2025-03-04), you can now use the closedby="none" attribute as a native solution to prevent modal from being closed by the Esc key.

<dialog closedby="none" id="myModal">
    <h3>Modal Title</h3>
    <p>The modal contents.</p>
</dialog>

<button onclick="document.getElementById('myModal').showModal()">Open Modal</button>

More info: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog#closedby

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: kenfai