Pak RT’s question in a real <dialog>: open it with showModal() or show(), then the browser answers where focus goes, whether the page behind still takes…
Confirmations, sign-in forms, warnings: modals are everywhere and most often wrong for accessibility. showModal() handles the top layer, an inert background, focus going in and back, Esc and ::backdrop. A method="dialog" form hands its answer back through returnValue. Less code, fewer bugs.
showModal() moves the dialog to the top layer and switches the rest off
show() taken for a modal show() is non-modal: no backdrop, the page is not inert, Esc does not close it. For a confirmation that must be answered, use showModal().method="dialog" on the form Without it the submit really sends the form and leaves the page. method="dialog" closes the dialog and sets returnValue. A Batal button in a form with a required input needs formnovalidate.::backdrop pseudo-element (say a dim colour + backdrop-filter: blur()). A home-made overlay div cannot join the top layer and ends up under the dialog.showModal(), then try the button behind Bayu cannot Tab there and Wulan’s click is caught by the backdrop: the rest of the page is inert.cancel event, then close. Esc is only a close request on a modal (or with closedby).show() and open it again No backdrop, the button behind still takes focus and clicks. That is a non-modal dialog.returnValue holds the clicked button’s value. Your code can read it in the close event.